Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'xss-mitigations' of https://github.com/jre-g/node-ecstatic
- Loading branch information
Showing
8 changed files
with
112 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var test = require('tap').test, | ||
ecstatic = require('../lib/ecstatic'), | ||
http = require('http'), | ||
request = require('request'), | ||
path = require('path'); | ||
|
||
var root = __dirname + '/public', | ||
baseDir = 'base'; | ||
|
||
test('directory listing with pathname including HTML characters', function (t) { | ||
var port = Math.floor(Math.random() * ((1<<16) - 1e4) + 1e4); | ||
|
||
var uri = 'http://localhost:' + port + path.join('/', baseDir, '/%3Cdir%3E'); | ||
|
||
var server = http.createServer( | ||
ecstatic({ | ||
root: root, | ||
baseDir: baseDir, | ||
showDir: true, | ||
autoIndex: false | ||
}) | ||
); | ||
|
||
server.listen(port, function () { | ||
request.get({ | ||
uri: uri | ||
}, function(err, res, body) { | ||
t.notMatch(body, /<dir>/, 'We didn\'t find the unencoded pathname'); | ||
t.match(body, /<dir>/, 'We found the encoded pathname'); | ||
server.close(); | ||
t.end(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var test = require('tap').test, | ||
ecstatic = require('../lib/ecstatic'), | ||
http = require('http'), | ||
request = require('request'), | ||
path = require('path'); | ||
|
||
var root = __dirname + '/public', | ||
baseDir = 'base'; | ||
|
||
test('directory listing with query string specified', function (t) { | ||
var port = Math.floor(Math.random() * ((1<<16) - 1e4) + 1e4); | ||
|
||
var uri = 'http://localhost:' + port + path.join('/', baseDir, '?a=1&b=2'); | ||
|
||
var server = http.createServer( | ||
ecstatic({ | ||
root: root, | ||
baseDir: baseDir, | ||
showDir: true, | ||
autoIndex: false | ||
}) | ||
); | ||
|
||
server.listen(port, function () { | ||
request.get({ | ||
uri: uri | ||
}, function(err, res, body) { | ||
t.match(body, /href="\/base\/subdir\/\?a=1&b=2"/, 'We found the encoded href'); | ||
t.notMatch(body, /a=1&b=2/, 'We didn\'t find the unencoded query string value'); | ||
server.close(); | ||
t.end(); | ||
}); | ||
}); | ||
}); |