Skip to content

Commit c37cafb

Browse files
committed
Improved security.
1 parent e2f3898 commit c37cafb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const REG_ENCODINGCLEANER = /[;\s]charset=utf-8/g;
6868
const REG_SKIPERROR = /epipe|invalid\sdistance/i;
6969
const REG_OLDCONF = /-/g;
7070
const REG_UTF8 = /[^\x20-\x7E]+/;
71-
const REG_TRAVEL = /(\/)?\.\.\//g;
7271
const FLAGS_INSTALL = ['get'];
7372
const FLAGS_DOWNLOAD = ['get', 'dnscache'];
7473
const QUERYPARSEROPTIONS = { maxKeys: 33 };
@@ -7327,7 +7326,19 @@ F.listener = function(req, res) {
73277326
var headers = req.headers;
73287327
req.$protocol = ((req.connection && req.connection.encrypted) || ((headers['x-forwarded-proto'] || ['x-forwarded-protocol']) === 'https')) ? 'https' : 'http';
73297328

7330-
req.url = req.url.replace(REG_TRAVEL, '');
7329+
var beg = 0;
7330+
7331+
// Removes directory browsing
7332+
for (var i = 0; i < req.url.length; i++) {
7333+
if (req.url[i] === '.' && req.url[i + 1] === '/')
7334+
beg = i + 1;
7335+
else if (req.url[i] === '?')
7336+
break;
7337+
}
7338+
7339+
if (beg)
7340+
req.url = req.url.substring(beg);
7341+
73317342
req.uri = framework_internal.parseURI(req);
73327343

73337344
F.stats.request.request++;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"name": "Sarp Aykent",
100100
"email": "[email protected]"
101101
}],
102-
"version": "3.2.0",
102+
"version": "3.2.1",
103103
"homepage": "http://www.totaljs.com",
104104
"bugs": {
105105
"url": "https://github.com/totaljs/framework/issues",

0 commit comments

Comments
 (0)