From fc754c9a1d035bf89f620725e8c4b1bbd6c15a2a Mon Sep 17 00:00:00 2001 From: Tom Hudson Date: Mon, 30 Mar 2020 17:08:47 +0100 Subject: [PATCH] Switches cacheKey from base64 of path to sha256 of path; fixes #3502 --- src/node/utils/caching_middleware.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/utils/caching_middleware.js b/src/node/utils/caching_middleware.js index c01a95fb3..5ef92b6f4 100644 --- a/src/node/utils/caching_middleware.js +++ b/src/node/utils/caching_middleware.js @@ -22,6 +22,7 @@ var zlib = require('zlib'); var settings = require('./Settings'); var semver = require('semver'); var existsSync = require('./path_exists'); +var crypto = require('crypto'); var CACHE_DIR = path.normalize(path.join(settings.root, 'var/')); CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined; @@ -49,7 +50,7 @@ CachingMiddleware.prototype = new function () { (req.get('Accept-Encoding') || '').indexOf('gzip') != -1; var path = require('url').parse(req.url).path; - var cacheKey = Buffer.from(path).toString('base64').replace(/[/+=]/g, ''); + var cacheKey = crypto.createHash('sha256').update(path).digest('hex'); fs.stat(CACHE_DIR + 'minified_' + cacheKey, function (error, stats) { var modifiedSince = (req.headers['if-modified-since']