diff options
author | Jordan Hollinger <jordan.hollinger@gmail.com> | 2012-06-13 15:20:29 -0400 |
---|---|---|
committer | Jordan Hollinger <jordan.hollinger@gmail.com> | 2012-06-13 15:20:29 -0400 |
commit | 6f37c0aaa6cf908a8d541720fc5deb9aa0378387 (patch) | |
tree | 7de7d09130f40621ebb28ae1faf54e8bc557d314 /src/node/hooks | |
parent | 48daf83a30199d5b316f2ca1add76704ffd14e61 (diff) | |
download | etherpad-lite-6f37c0aaa6cf908a8d541720fc5deb9aa0378387.zip |
The pad name sanitizer shouldn't drop query params. issue #779
Diffstat (limited to 'src/node/hooks')
-rw-r--r-- | src/node/hooks/express/padurlsanitize.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/node/hooks/express/padurlsanitize.js b/src/node/hooks/express/padurlsanitize.js index 4f5dd7a5..229d013d 100644 --- a/src/node/hooks/express/padurlsanitize.js +++ b/src/node/hooks/express/padurlsanitize.js @@ -1,4 +1,5 @@ var padManager = require('../../db/PadManager'); +var url = require('url'); exports.expressCreateServer = function (hook_name, args, cb) { //redirects browser to the pad's sanitized url if needed. otherwise, renders the html @@ -14,9 +15,11 @@ exports.expressCreateServer = function (hook_name, args, cb) { //the pad id was sanitized, so we redirect to the sanitized version if(sanitizedPadId != padId) { - var real_path = req.path.replace(/^\/p\/[^\/]+/, '/p/' + sanitizedPadId); - res.header('Location', real_path); - res.send('You should be redirected to <a href="' + real_path + '">' + real_path + '</a>', 302); + var real_url = req.url.replace(/^\/p\/[^\/]+/, '/p/' + sanitizedPadId); + var query = url.parse(req.url).query; + if ( query ) real_url += '?' + query; + res.header('Location', real_url); + res.send('You should be redirected to <a href="' + real_url + '">' + real_url + '</a>', 302); } //the pad id was fine, so just render it else |