summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Hollinger <jordan.hollinger@gmail.com>2012-06-13 15:48:58 -0400
committerJordan Hollinger <jordan.hollinger@gmail.com>2012-06-13 15:48:58 -0400
commit08a00af6171b9bae0365d8d9a9fdf7d7bf5b605a (patch)
treec13894c940bc821c64e4f03553c38bfc07f8dec6
parentb599cdf6e50a95d4de7aef3500281b324f03ec11 (diff)
downloadetherpad-lite-08a00af6171b9bae0365d8d9a9fdf7d7bf5b605a.zip
The pad name sanitizer shouldn't drop query params. issue #779
-rw-r--r--src/node/hooks/express/padurlsanitize.js9
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..957da42a 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