Rusty-Quartz / quartz_nbt

Provides support for encoding and decoding Minecraft's NBT format. This crate supports both zlib and gz compression, and also provides tools for converting NBT data to stringified NBT (SNBT) and vice versa.
https://crates.io/crates/quartz_nbt
MIT License
25 stars 10 forks source link

Fix incorrect SNBT string and key quoting #9

Closed Esper89 closed 1 year ago

Esper89 commented 1 year ago

SNBT strings and keys that start with a number (or that start or end with whitespace) need to be quoted to preserve their value and type. Currently, if you run this library's SNBT output back into it's own SNBT parser:

I encountered this problem while formatting a level.dat file as SNBT and parsing the output—version strings like "1.19.4" caused parse errors, and the values of game rules like randomTickSpeed: "3" were incorrectly converted from strings to integers.

This PR fixes these issues.

Cassy343 commented 1 year ago

Thanks for pointing out these issues and fixing them. Could you add some tests consisting of the cases you outlined in your description?

Esper89 commented 1 year ago

I've added the test cases.

Cassy343 commented 1 year ago

Thanks, looks good to me.

Cassy343 commented 1 year ago

Released in version 0.2.8