fix: #8757, allow all slashes in category route

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 0a4fd50aac
commit 1ee9384875

@ -59,7 +59,7 @@ module.exports = function (User) {
settings.restrictChat = parseInt(getSetting(settings, 'restrictChat', 0), 10) === 1;
settings.topicSearchEnabled = parseInt(getSetting(settings, 'topicSearchEnabled', 0), 10) === 1;
settings.bootswatchSkin = validator.escape(String(settings.bootswatchSkin || ''));
settings.homePageRoute = validator.escape(String(settings.homePageRoute || '')).replace('/', '/');
settings.homePageRoute = validator.escape(String(settings.homePageRoute || '')).replace(///g, '/');
settings.scrollToMyPost = parseInt(getSetting(settings, 'scrollToMyPost', 1), 10) === 1;
settings.categoryWatchState = getSetting(settings, 'categoryWatchState', 'notwatching');

@ -1706,6 +1706,37 @@ describe('User', function () {
});
});
it('should properly escape homePageRoute', function (done) {
var data = {
uid: testUid,
settings: {
bootswatchSkin: 'default',
homePageRoute: 'category/6/testing-ground',
homePageCustom: '',
openOutgoingLinksInNewTab: 0,
scrollToMyPost: 1,
userLang: 'en-GB',
usePagination: 1,
topicsPerPage: '10',
postsPerPage: '5',
showemail: 1,
showfullname: 1,
restrictChat: 0,
followTopicsOnCreate: 1,
followTopicsOnReply: 1,
},
};
socketUser.saveSettings({ uid: testUid }, data, function (err) {
assert.ifError(err);
User.getSettings(testUid, function (err, data) {
assert.ifError(err);
assert.strictEqual(data.homePageRoute, 'category/6/testing-ground');
done();
});
});
});
it('should error if language is invalid', function (done) {
var data = {
uid: testUid,

Loading…
Cancel
Save