mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 06:25:51 +03:00
Merge pull request #5851 from Gargol/issue-5808-error-500-with-illegal-character
Returns 404 page instead of crashing when special chars are used in tag slugs
This commit is contained in:
commit
09d0d5d26e
@ -14,6 +14,7 @@ var _ = require('lodash'),
|
||||
Promise = require('bluebird'),
|
||||
template = require('../helpers/template'),
|
||||
routeMatch = require('path-match')(),
|
||||
safeString = require('../utils/index').safeString,
|
||||
|
||||
frontendControllers,
|
||||
staticPostPermalink = routeMatch('/:slug/:edit?');
|
||||
@ -160,8 +161,8 @@ function renderChannel(channelOpts) {
|
||||
filter, filterKey;
|
||||
|
||||
// Add the slug if it exists in the route
|
||||
if (channelOpts.route.indexOf(':slug') !== -1) {
|
||||
options[channelOpts.name] = req.params.slug;
|
||||
if (channelOpts.route.indexOf(':slug') !== -1 && req.params.slug) {
|
||||
options[channelOpts.name] = safeString(req.params.slug);
|
||||
hasSlug = true;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,14 @@ describe('Frontend Routing', function () {
|
||||
.end(doEnd(done));
|
||||
});
|
||||
|
||||
it('should 404 for unknown tag with invalid characters', function (done) {
|
||||
request.get('/tag/~$pectacular~/')
|
||||
.expect('Cache-Control', testUtils.cacheRules['private'])
|
||||
.expect(404)
|
||||
.expect(/Page not found/)
|
||||
.end(doEnd(done));
|
||||
});
|
||||
|
||||
it('should 404 for unknown author', function (done) {
|
||||
request.get('/author/spectacular/')
|
||||
.expect('Cache-Control', testUtils.cacheRules['private'])
|
||||
|
Loading…
Reference in New Issue
Block a user