diff --git a/doc/api/http_api.md b/doc/api/http_api.md index 990d1b498..b10178fb7 100644 --- a/doc/api/http_api.md +++ b/doc/api/http_api.md @@ -295,10 +295,10 @@ Group pads are normal pads, but with the name schema GROUPID$PADNAME. A security #### createPad(padID [, text]) * API >= 1 -creates a new (non-group) pad. Note that if you need to create a group Pad, you should call **createGroupPad**. +creates a new (non-group) pad. Note that if you need to create a group Pad, you should call **createGroupPad**. Returns the actual PadID that was recorded (Checked against a regex so that nothing breaks when accessed.) *Example returns:* - * `{code: 0, message:"ok", data: null}` + * `{code: 0, message:"ok", data: {"padID":"asdf_as_d"}}` * `{code: 1, message:"pad does already exist", data: null}` #### getRevisionsCount(padID) diff --git a/src/node/db/API.js b/src/node/db/API.js index 4979e8c65..cd0835b4f 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -331,12 +331,12 @@ exports.createPad = function(padID, text, callback) callback(new customError("createPad can't create group pads","apierror")); return; } - + padID = padID.replace(/[;\/\?:@&=\+\$,{}\\\^\[\]\`\|%<>\*#]/gi, '_'); //create pad getPadSafe(padID, false, text, function(err) { if(ERR(err, callback)) return; - callback(); + callback(null, {padID: padID}); }); } diff --git a/src/node/hooks/express/specialpages.js b/src/node/hooks/express/specialpages.js index 440024614..6deb8650d 100644 --- a/src/node/hooks/express/specialpages.js +++ b/src/node/hooks/express/specialpages.js @@ -27,7 +27,11 @@ exports.expressCreateServer = function (hook_name, args, cb) { //serve pad.html under /p args.app.get('/p/:pad', function(req, res, next) { - res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {req: req})); + /*if(!!(req.params.pad.match(/[;\/\?:@&=\+\$,{}\\\^\[\]\`\|%<>\*#]/gi))){ + res.send(404, "Such a padname is forbidden"); + }else{*/ + res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {req: req})); + //} }); //serve timeslider.html under /p/$padname/timeslider @@ -35,7 +39,16 @@ exports.expressCreateServer = function (hook_name, args, cb) { { res.send(eejs.require("ep_etherpad-lite/templates/timeslider.html", {req: req})); }); - + args.app.get('/p/:pad/*', function(req, res, next) + { + if(req.url.split("/")[3] == "timeslider"){ + //Just a safeguard, sometimes these URLs get messed up and should be + //actually rerouted to the timeslider instead of an error page. + res.send(eejs.require("ep_etherpad-lite/templates/timeslider.html", {req: req})); + }else{ + res.send(404, "Such a padname is forbidden"); + } + }); //serve favicon.ico from all path levels except as a pad name args.app.get( /\/favicon.ico$/, function(req, res) { diff --git a/src/templates/index.html b/src/templates/index.html index 9fd33a26a..950c28b64 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -41,7 +41,7 @@ if(language) document.documentElement.lang = language[1]; })(document) - +