Skip to content

Commit

Permalink
Fix not sanitizing file names rendered in html
Browse files Browse the repository at this point in the history
  • Loading branch information
omphalos committed Feb 14, 2018
1 parent 0c45fc6 commit 4155bfe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crud-file-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ exports.handleRequest = function(vpath, path, req, res, readOnly, logHeadRequest
var name = results[f].name;
var normalized = url + '/' + name;
while(normalized[0] == '/') { normalized = normalized.slice(1, normalized.length); }
res.write('\r\n<p><a href="/' + normalized + '">' + name + '</a></p>');
if(normalized.indexOf('"') >= 0) throw new Error('unsupported file name')
name = name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
res.write('\r\n<p><a href="/' + normalized + '"><span>' + name + '</span></a></p>');
}
res.end('\r\n</body></html>');
}
Expand Down

0 comments on commit 4155bfe

Please # to comment.