Stop parsing argument in argfile when quote ends
There are two visible effects of this change:
1) If an empty argument is passed in quotes, it will be parsed as an
empty string and handled by the compiler, which will report an error
later. The specific error is not very important because it's an edge
case anyway; at the moment, "source file or directory not found:" is
reported which is no better than the "invalid flag:" error reported
by javac in the similar case
2) It's no longer possible to split an argument into several parts and
quote them separately, such as:
"-langu"ag"e-"ver'sio'n 1.2
No test added for this change in behavior since it's an even edgier
case. Note that javac also prohibits this.
#KT-27226 Fixed
This commit is contained in:
+4
-1
@@ -62,7 +62,10 @@ private fun Reader.parseNextArgument(): String? {
|
||||
if (r.isWhitespace()) break
|
||||
|
||||
when (r) {
|
||||
DOUBLE_QUOTE, SINGLE_QUOTE -> consumeRestOfEscapedSequence(sb, r)
|
||||
DOUBLE_QUOTE, SINGLE_QUOTE -> {
|
||||
consumeRestOfEscapedSequence(sb, r)
|
||||
return sb.toString()
|
||||
}
|
||||
BACKSLASH -> nextChar()?.apply(sb::append)
|
||||
else -> sb.append(r)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
""
|
||||
-include-runtime
|
||||
-progressive
|
||||
@@ -0,0 +1 @@
|
||||
@$TESTDATA_DIR$/argfileWithEmptyArgument.argfile
|
||||
@@ -0,0 +1,2 @@
|
||||
error: source file or directory not found:
|
||||
COMPILATION_ERROR
|
||||
@@ -66,6 +66,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/apiVersionLessThanLanguageUsingArgfile.args");
|
||||
}
|
||||
|
||||
@TestMetadata("argfileWithEmptyArgument.args")
|
||||
public void testArgfileWithEmptyArgument() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/argfileWithEmptyArgument.args");
|
||||
}
|
||||
|
||||
@TestMetadata("argfileWithEscaping.args")
|
||||
public void testArgfileWithEscaping() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/argfileWithEscaping.args");
|
||||
|
||||
Reference in New Issue
Block a user