Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow safe files on certain subdomains #63

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/Quest_for_the_Teacup_of_Minor_Sentimental_Value.zip
'2k788xeots',
])

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
Loading