mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
fix pads with spaces (#4884)
This commit is contained in:
parent
68c4ed7189
commit
377883db98
2 changed files with 25 additions and 1 deletions
|
@ -18,7 +18,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
|||
next();
|
||||
} else {
|
||||
// the pad id was sanitized, so we redirect to the sanitized version
|
||||
const realURL = encodeURIComponent(sanitizedPadId) + new URL(req.url).search;
|
||||
const realURL = encodeURIComponent(sanitizedPadId) + new URL(req.url, 'http://invalid.invalid').search;
|
||||
res.header('Location', realURL);
|
||||
res.status(302).send(`You should be redirected to <a href="${realURL}">${realURL}</a>`);
|
||||
}
|
||||
|
|
24
src/tests/backend/specs/pads-with-spaces.js
Normal file
24
src/tests/backend/specs/pads-with-spaces.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('../assert-legacy').strict;
|
||||
|
||||
let agent;
|
||||
|
||||
describe(__filename, function () {
|
||||
before(async function () {
|
||||
agent = await common.init();
|
||||
});
|
||||
|
||||
it('supports pads with spaces, regression test for #4883', async function () {
|
||||
await agent.get('/p/pads with spaces')
|
||||
.expect(302)
|
||||
.expect('location', 'pads_with_spaces');
|
||||
});
|
||||
|
||||
it('supports pads with spaces and query, regression test for #4883', async function () {
|
||||
await agent.get('/p/pads with spaces?showChat=true&noColors=false')
|
||||
.expect(302)
|
||||
.expect('location', 'pads_with_spaces?showChat=true&noColors=false');
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue