mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-27 12:46:22 +01:00
Tolerate missing terminating newlines in Java release files
Had a report out in the wild of a release file that doesn't end in a terminating newline, which was causing the parser to blow up. This commit relaxes the parsing to tolerate EOFs while parsing values.
This commit is contained in:
parent
1c663e1c04
commit
9bd7df4d3c
@ -85,23 +85,28 @@ public class EnvironmentParser {
|
||||
private String parseValue() throws IOException {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
while (true) {
|
||||
char c = read();
|
||||
try {
|
||||
while (true) {
|
||||
char c = read();
|
||||
|
||||
switch (c) {
|
||||
case '\r':
|
||||
case '\n':
|
||||
return buffer.toString();
|
||||
case '"':
|
||||
buffer.append(parseQuotedPhrase());
|
||||
break;
|
||||
case '\\':
|
||||
char next = read();
|
||||
buffer.append(next);
|
||||
break;
|
||||
default:
|
||||
buffer.append(c);
|
||||
switch (c) {
|
||||
case '\r':
|
||||
case '\n':
|
||||
return buffer.toString();
|
||||
case '"':
|
||||
buffer.append(parseQuotedPhrase());
|
||||
break;
|
||||
case '\\':
|
||||
char next = read();
|
||||
buffer.append(next);
|
||||
break;
|
||||
default:
|
||||
buffer.append(c);
|
||||
}
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
// No terminating newline. bad!
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user