Fix SNBT Parsing and writing of single quoted strings, and strings with quotes or single quotes within.
This commit is contained in:
parent
bdb087fabc
commit
18e98ca918
9 changed files with 93 additions and 14 deletions
|
@ -67,6 +67,12 @@ enum TagType {
|
|||
break;
|
||||
}
|
||||
|
||||
if (val == "'") {
|
||||
reader.next();
|
||||
isQuoted = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (val == '{') {
|
||||
ret = TagType.Compound; // Detected a CompoundTag
|
||||
reader.next(); // Consume '{'
|
||||
|
@ -251,7 +257,13 @@ abstract class Tag {
|
|||
TagType type = TagType.getStringifiedTagType(string);
|
||||
Tag tag = Tag.makeTagOfType(type);
|
||||
tag._key = name;
|
||||
tag.readStringifiedValue(string);
|
||||
try {
|
||||
tag.readStringifiedValue(string);
|
||||
} catch (E, stack) {
|
||||
print(E);
|
||||
print(string.getSnapshot());
|
||||
print(stack);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
@ -286,6 +298,14 @@ abstract class Tag {
|
|||
}
|
||||
}
|
||||
|
||||
bool shouldUseSingleQuotes(String value) {
|
||||
return value.contains("\"");
|
||||
}
|
||||
|
||||
bool shouldEscapeSingleQuotes(String value) {
|
||||
return value.contains("'");
|
||||
}
|
||||
|
||||
void writeStringifiedValue(StringBuilder builder, int indent, bool isList);
|
||||
void readStringifiedValue(StringReader reader);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue