Read quoted arguments from parameter files, and refuse a file that in… · openjavaformat/open-java-format@f5e6b12 · GitHub
Skip to content

Commit f5e6b12

Browse files
kfriedbergerabashev
authored andcommitted
Read quoted arguments from parameter files, and refuse a file that includes itself
CommandLineOptionsParser split an @argfile at every whitespace character and knew no quotes, so a path with a space in it became several arguments. Each was reported as "Skipping non-Java file", and the run still exited 0 (#40, from google/google-java-format#421). A parameter file that included itself recursed until the stack overflowed. This ports google/google-java-format#931 by Karlheinz Friedberger, its three commits squashed into one. An argument in a parameter file may be quoted with double or single quotes and then keeps its whitespace; an unclosed quote runs to the end of the file; and a file that is already being read is reported as "parameter file was included recursively". Escaped quotes are not handled, as upstream. The three CommandLineOptionsParserTest cases come from that PR.
1 parent e2142e5 commit f5e6b12

2 files changed

Lines changed: 106 additions & 14 deletions

File tree

‎open-java-format/src/main/java/com/palantir/javaformat/java/CommandLineOptionsParser.java‎

Lines changed: 50 additions & 14 deletions

‎open-java-format/src/test/java/com/palantir/javaformat/java/CommandLineOptionsParserTest.java‎

Lines changed: 56 additions & 0 deletions

0 commit comments

Comments
 (0)