mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 06:25:51 +03:00
Merge pull request #3898 from halfdan/fix-uncap-api
Restrict uncapitalise middleware for API
This commit is contained in:
commit
6ea7ab3294
@ -155,11 +155,17 @@ function redirectToSetup(req, res, next) {
|
||||
// Detect uppercase in req.path
|
||||
function uncapitalise(req, res, next) {
|
||||
var pathToTest = req.path,
|
||||
isSignupOrReset = req.path.match(/(\/ghost\/(signup|reset)\/)/i);
|
||||
isSignupOrReset = req.path.match(/(\/ghost\/(signup|reset)\/)/i),
|
||||
isAPI = req.path.match(/(\/ghost\/api\/v0[\d\.]+\/.*?\/)/i);
|
||||
|
||||
if (isSignupOrReset) {
|
||||
pathToTest = isSignupOrReset[1];
|
||||
}
|
||||
|
||||
// Do not lowercase anything after /api/v0.1/ to protect :key/:slug
|
||||
if (isAPI) {
|
||||
pathToTest = isAPI[1];
|
||||
}
|
||||
|
||||
if (/[A-Z]/.test(pathToTest)) {
|
||||
res.set('Cache-Control', 'public, max-age=' + utils.ONE_YEAR_S);
|
||||
|
Loading…
Reference in New Issue
Block a user