robojumper / DarkestDungeonSaveEditor

Darkest Dungeon Save File (.json) Reader, Writer, Editor. Also, Spreadsheets.
MIT License
75 stars 8 forks source link

Save files may contain invalid UTF-8 #27

Open robojumper opened 3 years ago

robojumper commented 3 years ago

26 provided a

persist.map.json that contains the null-terminated byte sequence 72 6F 6F 80 00 as an object name, presumably a room name. Room names are generated by taking the string roo and appending a single ASCII character to it. The game seems to have run out of room names by going outside of the ASCII character range with the 80. This makes the object name invalid UTF-8 and both implementations reject it.

I'm inclined to not fix this. This could possibly be be fixed in the Java impl here

https://github.com/robojumper/DarkestDungeonSaveEditor/blob/f580c050a169639ea53c6a62319832b425fcbfd5/src/main/java/de/robojumper/ddsavereader/file/DsonFile.java#L205-L216

and in the Rust impl here

https://github.com/robojumper/DarkestDungeonSaveEditor/blob/f580c050a169639ea53c6a62319832b425fcbfd5/rust/ddsaveedit/ddsavelib/src/file/bin.rs#L450-L453

and here (need support for byte escape sequences)

https://github.com/robojumper/DarkestDungeonSaveEditor/blob/f580c050a169639ea53c6a62319832b425fcbfd5/rust/ddsaveedit/ddsavelib/src/util.rs#L10-L67