Skip to content
Snippets Groups Projects
Commit 497f5f3c authored by julian.baeume's avatar julian.baeume :pick:
Browse files

Fix: Compression allowlist Regex too greedy

Root cause: mime types might contain charset information
Solution: be more relaxed about anything following the actual mime type
parent a3025712
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,8 @@ const gzip = promisify(zlib.gzip) ...@@ -11,7 +11,8 @@ const gzip = promisify(zlib.gzip)
const compressFileSize = Number(process.env.COMPRESS_FILE_SIZE) const compressFileSize = Number(process.env.COMPRESS_FILE_SIZE)
const compressionMimeTypes = (process.env.COMPRESS_FILE_TYPES || '').replace(/([.+*?^$()[\]{}|])/g, '\\$1').split(' ') const compressionMimeTypes = (process.env.COMPRESS_FILE_TYPES || '').replace(/([.+*?^$()[\]{}|])/g, '\\$1').split(' ')
const compressionWhitelistRegex = new RegExp(`^(${compressionMimeTypes.join('|')})$`) const compressionWhitelistRegex = new RegExp(`^(${compressionMimeTypes.join('|')})($|;)`, 'i')
export function createWritable (body) { export function createWritable (body) {
if (typeof body !== 'string' && !(body instanceof Buffer)) return JSON.stringify(body) if (typeof body !== 'string' && !(body instanceof Buffer)) return JSON.stringify(body)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment