mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
🐛Fixed short urls when private blogging is enabled (#9628)
close #9578 - updated condition to disable RSS for private blog - use regex - ensure private rss feed still works
This commit is contained in:
parent
a993994d68
commit
3afc2654aa
2 changed files with 69 additions and 1 deletions
|
@ -70,7 +70,7 @@ privateBlogging = {
|
|||
// NOTE: Redirect to /private if the session does not exist.
|
||||
privateBlogging.authenticatePrivateSession(req, res, function onSessionVerified() {
|
||||
// CASE: RSS is disabled for private blogging e.g. they create overhead
|
||||
if (req.path.lastIndexOf('/rss/', 0) === 0 || req.path.lastIndexOf('/rss/') === req.url.length - 5) {
|
||||
if (req.path.match(/\/rss(\/?|\/\d+\/?)$/)) {
|
||||
return next(new common.errors.NotFoundError({
|
||||
message: common.i18n.t('errors.errors.pageNotFound')
|
||||
}));
|
||||
|
|
|
@ -259,6 +259,23 @@ describe('Private Blogging', function () {
|
|||
(next.firstCall.args[0] instanceof common.errors.NotFoundError).should.eql(true);
|
||||
});
|
||||
|
||||
it('filterPrivateRoutes should 404 for rss with pagination requests', function () {
|
||||
var salt = Date.now().toString();
|
||||
req.url = req.path = '/rss/1';
|
||||
|
||||
req.session = {
|
||||
token: hash('rightpassword', salt),
|
||||
salt: salt
|
||||
};
|
||||
|
||||
res.isPrivateBlog = true;
|
||||
res.redirect = sandbox.spy();
|
||||
|
||||
privateBlogging.filterPrivateRoutes(req, res, next);
|
||||
next.called.should.be.true();
|
||||
(next.firstCall.args[0] instanceof common.errors.NotFoundError).should.eql(true);
|
||||
});
|
||||
|
||||
it('filterPrivateRoutes should 404 for tag rss requests', function () {
|
||||
var salt = Date.now().toString();
|
||||
req.url = req.path = '/tag/welcome/rss/';
|
||||
|
@ -276,6 +293,57 @@ describe('Private Blogging', function () {
|
|||
(next.firstCall.args[0] instanceof common.errors.NotFoundError).should.eql(true);
|
||||
});
|
||||
|
||||
it('filterPrivateRoutes should 404 for tag rss with pagination requests', function () {
|
||||
var salt = Date.now().toString();
|
||||
req.url = req.path = '/tag/welcome/rss/2';
|
||||
|
||||
req.session = {
|
||||
token: hash('rightpassword', salt),
|
||||
salt: salt
|
||||
};
|
||||
|
||||
res.isPrivateBlog = true;
|
||||
res.redirect = sandbox.spy();
|
||||
|
||||
privateBlogging.filterPrivateRoutes(req, res, next);
|
||||
next.called.should.be.true();
|
||||
(next.firstCall.args[0] instanceof common.errors.NotFoundError).should.eql(true);
|
||||
});
|
||||
|
||||
it('filterPrivateRoutes should return next if tag contains rss', function () {
|
||||
var salt = Date.now().toString();
|
||||
req.url = req.path = '/tag/rss-test/';
|
||||
|
||||
req.session = {
|
||||
token: hash('rightpassword', salt),
|
||||
salt: salt
|
||||
};
|
||||
|
||||
res.isPrivateBlog = true;
|
||||
res.redirect = sandbox.spy();
|
||||
|
||||
privateBlogging.filterPrivateRoutes(req, res, next);
|
||||
next.called.should.be.true();
|
||||
next.firstCall.args.length.should.equal(0);
|
||||
});
|
||||
|
||||
it('filterPrivateRoutes should not 404 for very short post url', function () {
|
||||
var salt = Date.now().toString();
|
||||
req.url = req.path = '/ab/';
|
||||
|
||||
req.session = {
|
||||
token: hash('rightpassword', salt),
|
||||
salt: salt
|
||||
};
|
||||
|
||||
res.isPrivateBlog = true;
|
||||
res.redirect = sandbox.spy();
|
||||
|
||||
privateBlogging.filterPrivateRoutes(req, res, next);
|
||||
next.called.should.be.true();
|
||||
next.firstCall.args.length.should.equal(0);
|
||||
});
|
||||
|
||||
it('filterPrivateRoutes: allow private /rss/ feed', function () {
|
||||
settingsStub.withArgs('public_hash').returns('777aaa');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue