lizzieyzy
lizzieyzy copied to clipboard
LizzieYZY corrupts SGFs that have custom tags with bracket characters when saving them.
Other SGF editors and servers sometimes write custom tags into SGF files, such as CGOS. Those tags sometimes contain "]" characters within them, escaped. For example, the following is an SGF with a custom "CC" tag:
(;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2]
RU[Chinese]SZ[9]KM[7.00]
PW[]PB[]DT[2023-06-08]
;B[fe]
;W[de]C[test[\]]CC[test[\]])
The "CC" tag contains the string "test[]", and the "]" character in that string is escaped with a "\" character so that it isn't confused as one of the "]" in the SGF format itself.
If you load this SGF and then immediately save it again in LizzieYZY, you obtain a corrupted SGF:
(;FF[4]ST[2]KM[7.0]RU[Chinese]GM[1]SZ[9]PW[]AP[Lizzie: 2.5.2]DT[2023-06-08]PB[]RE[]DZ[G]CA[UTF-8];B[fe];W[de]CC[test[]]C[test[\]])
You can see that the closing bracket in the "CC" tag is no longer escaped with a "\":
CC[test[]]
It should instead be:
CC[test[\]]
This SGF then becomes invalid and other programs are unable to parse it.
We can see that that LizzieYZY does escape the closing bracket properly in the C tag, so that's good. The bugfix should be that LizzieYZY needs to escape closing bracket characters in all tags, not just the C tag.
Right now in particular this affects some of the SGF files from the computer Go server (http://www.yss-aya.com/cgos/), that's where I ran into this issue. Some of these files contain escaped closing brackets in custom tags that describe additional information from CGOS about the bot's analysis. If you try to open the affected files in LizzieYZY and save them again, you obtain corrupted files and if the SGF file contains many variations, it becomes very hard to fix and recover a valid SGF again.
Thanks for the report. save slash for all tags is reasonable.