Skip to content

Commit

Permalink
add error if response file name is empty or invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
enricosada committed Jan 18, 2016
1 parent 015001d commit 20f0552
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/fsharp/CompileOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,20 @@ let ParseCompilerOptions (collectOtherArgument : string -> unit, blocks: Compile
| [] -> ()
| ((rsp: string) :: t) when rsp.StartsWith("@") ->
let responseFileOptions =
let path = rsp.TrimStart('@') |> FileSystem.GetFullPathShim

if not (FileSystem.SafeExists path) then
let fullpath =
try
Some (rsp.TrimStart('@') |> FileSystem.GetFullPathShim)
with _ ->
None

match fullpath with
| None ->
errorR(Error(FSComp.SR.optsResponseFileNameInvalid(rsp),rangeCmdArgs))
[]
| Some(path) when not (FileSystem.SafeExists path) ->
errorR(Error(FSComp.SR.optsResponseFileNotFound(rsp, path),rangeCmdArgs))
[]
else
| Some path ->
match ResponseFile.parseFile path with
| Choice2Of2 _ ->
errorR(Error(FSComp.SR.optsInvalidResponseFile(rsp, path),rangeCmdArgs))
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1266,3 +1266,4 @@ estApplyStaticArgumentsForMethodNotImplemented,"A type provider implemented GetS
3190,checkLowercaseLiteralBindingInPattern,"Lowercase literal '%s' is being shadowed by a new pattern with the same name. Only uppercase and module-prefixed literals can be used as named patterns."
3191,optsInvalidResponseFile,"Invalid response file '%s' ( '%s' )"
3192,optsResponseFileNotFound,"Response file '%s' not found in '%s'"
3193,optsResponseFileNameInvalid,"Response file name '%s' is empty, contains invalid characters, has a drive specification without an absolute path, or is too long"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// #NoMT #CompilerOptions
//<Expects id="FS3192" status="error"></Expects>
exit 0
exit 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// #NoMT #CompilerOptions
//<Expects id="FS3193" status="error"></Expects>
exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
SOURCE="responsefile01.fs \@empty_rs.rsp \@rs2.rsp \@empty_rs.rsp " # responsefile01.fs nested response file
SOURCE="responsefile02.fs" SCFLAGS="\@rs1_multiline_and_comments.rsp" # responsefile02.fs response file multiline
SOURCE="E_responsefile_not_found.fs" COMPILE_ONLY=1 SCFLAGS="\@not_exists" # E_responsefile_not_found.fs error if response file does not exists
SOURCE="E_responsefile_path_invalid.fs" COMPILE_ONLY=1 SCFLAGS="\@" # E_responsefile_path_invalid.fs error if response file name is empty or invalid

0 comments on commit 20f0552

Please sign in to comment.