4 Commits

Author SHA1 Message Date
James Allen
81e85de169 Release version 0.1.3 2015-02-26 11:20:56 +00:00
Brian Gough
f37004cec6 update sanitizePath regex
remove accidental inclusion of , and add null char \x00
2015-02-13 11:28:43 +00:00
James Allen
1a7500f102 Allow non-latin characters in the rootResourcePath 2015-02-13 11:21:35 +00:00
James Allen
90cda12ed9 Sanitize rootResourcePath 2015-02-11 16:39:43 +00:00
3 changed files with 15 additions and 3 deletions

View File

@@ -27,10 +27,12 @@ module.exports = RequestParser =
response.timeout = response.timeout * 1000 # milliseconds response.timeout = response.timeout * 1000 # milliseconds
response.resources = (@_parseResource(resource) for resource in (compile.resources or [])) response.resources = (@_parseResource(resource) for resource in (compile.resources or []))
response.rootResourcePath = @_parseAttribute "rootResourcePath",
rootResourcePath = @_parseAttribute "rootResourcePath",
compile.rootResourcePath compile.rootResourcePath
default: "main.tex" default: "main.tex"
type: "string" type: "string"
response.rootResourcePath = RequestParser._sanitizePath(rootResourcePath)
catch error catch error
return callback error return callback error
@@ -72,3 +74,6 @@ module.exports = RequestParser =
throw "Default not implemented" throw "Default not implemented"
return attribute return attribute
_sanitizePath: (path) ->
# See http://php.net/manual/en/function.escapeshellcmd.php
path.replace(/[\#\&\;\`\|\*\?\~\<\>\^\(\)\[\]\{\}\$\\\x0A\xFF\x00]/g, "")

View File

@@ -1,7 +1,7 @@
{ {
"name": "node-clsi", "name": "node-clsi",
"description": "A Node.js implementation of the CLSI LaTeX web-API", "description": "A Node.js implementation of the CLSI LaTeX web-API",
"version": "0.1.2", "version": "0.1.3",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/sharelatex/clsi-sharelatex.git" "url": "https://github.com/sharelatex/clsi-sharelatex.git"

View File

@@ -204,6 +204,13 @@ describe "RequestParser", ->
@callback.calledWith("rootResourcePath attribute should be a string") @callback.calledWith("rootResourcePath attribute should be a string")
.should.equal true .should.equal true
describe "with a root resource path that needs escaping", ->
beforeEach ->
@validRequest.compile.rootResourcePath = "`rm -rf foo`.tex"
@RequestParser.parse @validRequest, @callback
@data = @callback.args[0][1]
it "should return the escaped resource", ->
@data.rootResourcePath.should.equal "rm -rf foo.tex"