Skip to content

Commit d25ef68

Browse files
Fix SNBT encoding of empty keys (#148)
If the key is empty it must be surrounded by quotes.
1 parent a986c8c commit d25ef68

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/amulet/nbt/nbt_encoding/string/write_string.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ namespace NBT {
223223

224224
inline void write_key(std::string& snbt, const StringTag& key)
225225
{
226-
if (std::all_of(key.begin(), key.end(), [](char c) {
226+
if (key.empty()) {
227+
snbt.append("\"\"");
228+
} else if (
229+
std::all_of(key.begin(), key.end(), [](char c) {
227230
return std::isalnum(c) || c == '.' || c == '_' || c == '+' || c == '-';
228231
})) {
229232
snbt.append(key);

0 commit comments

Comments
 (0)