mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Sanitize rootResourcePath
This commit is contained in:
parent
1f8ddac27d
commit
561ce7dc60
2 changed files with 13 additions and 2 deletions
|
@ -27,10 +27,12 @@ module.exports = RequestParser =
|
|||
response.timeout = response.timeout * 1000 # milliseconds
|
||||
|
||||
response.resources = (@_parseResource(resource) for resource in (compile.resources or []))
|
||||
response.rootResourcePath = @_parseAttribute "rootResourcePath",
|
||||
|
||||
rootResourcePath = @_parseAttribute "rootResourcePath",
|
||||
compile.rootResourcePath
|
||||
default: "main.tex"
|
||||
type: "string"
|
||||
response.rootResourcePath = RequestParser._sanitizePath(rootResourcePath)
|
||||
catch error
|
||||
return callback error
|
||||
|
||||
|
@ -72,3 +74,5 @@ module.exports = RequestParser =
|
|||
throw "Default not implemented"
|
||||
return attribute
|
||||
|
||||
_sanitizePath: (path) ->
|
||||
path.replace(/[^a-zA-Z0-9_\-;.,\/ ]/g, "")
|
|
@ -204,6 +204,13 @@ describe "RequestParser", ->
|
|||
@callback.calledWith("rootResourcePath attribute should be a string")
|
||||
.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"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue