Do not use backslash for escaping outside of string literals in argfiles
This fixes CLI tests testArgfileWithEscaping and testApiVersionLessThanLanguageUsingArgfile on Windows #KT-28180 Fixed
This commit is contained in:
+5
-8
@@ -61,22 +61,19 @@ private fun Reader.parseNextArgument(): String? {
|
|||||||
while (r != null) {
|
while (r != null) {
|
||||||
if (r.isWhitespace()) break
|
if (r.isWhitespace()) break
|
||||||
|
|
||||||
when (r) {
|
if (r == DOUBLE_QUOTE || r == SINGLE_QUOTE) {
|
||||||
DOUBLE_QUOTE, SINGLE_QUOTE -> {
|
consumeRestOfQuotedSequence(sb, r)
|
||||||
consumeRestOfEscapedSequence(sb, r)
|
return sb.toString()
|
||||||
return sb.toString()
|
|
||||||
}
|
|
||||||
BACKSLASH -> nextChar()?.apply(sb::append)
|
|
||||||
else -> sb.append(r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb.append(r)
|
||||||
r = nextChar()
|
r = nextChar()
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString().takeIf { it.isNotEmpty() }
|
return sb.toString().takeIf { it.isNotEmpty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Reader.consumeRestOfEscapedSequence(sb: StringBuilder, quote: Char) {
|
private fun Reader.consumeRestOfQuotedSequence(sb: StringBuilder, quote: Char) {
|
||||||
var ch = nextChar()
|
var ch = nextChar()
|
||||||
while (ch != null && ch != quote) {
|
while (ch != null && ch != quote) {
|
||||||
if (ch == BACKSLASH) nextChar()?.apply(sb::append) else sb.append(ch)
|
if (ch == BACKSLASH) nextChar()?.apply(sb::append) else sb.append(ch)
|
||||||
|
|||||||
Reference in New Issue
Block a user