Skip to content

Commit

Permalink
Allow safe files on certain subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
dfabulich committed Sep 5, 2024
1 parent 13b71e7 commit 8769fe8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import * as templates from './templates.js'
const PATH_PARTS = /^\/([0-9a-zA-Z]+)\/?(.*)$/
const VALID_ORIGINS = /^(https?:\/\/(mirror\.|www\.)?ifarchive\.org)?\//

// https://github.com/iftechfoundation/ifarchive-unbox/issues/61
// When adding subdomains to this list, we need to manually add them in the Cloudflare admin tool
const ALLOWED_SUBDOMAINS = new Set([
// /if-archive/games/competition2024/Games/QftToMSV-Windows-and-Linux.zip
'23nwbwjk2e',
])

export default class UnboxApp {
constructor(options, cache, index) {
this.cache = cache
Expand Down Expand Up @@ -78,7 +85,7 @@ export default class UnboxApp {
}

// Safe file on non-subdomain
if (subdomain_count === 1 && !UNSAFE_FILES.test(path)) {
if (subdomain_count === 1 && !UNSAFE_FILES.test(path) && !ALLOWED_SUBDOMAINS.has(ctx.subdomains[0])) {
ctx.status = 301
ctx.redirect(`//${domain}${path}`)
return
Expand Down

0 comments on commit 8769fe8

Please sign in to comment.