Repository navigation
escape tuple labels in generate_gml - #8755
Conversation
dschult
left a comment
There was a problem hiding this comment.
Thanks for this! Looks like a case that slipped through -- just as you seem to have inferred. I have a minor suggestion that allows the expected string for one assert to avoid using escapes so it is easier to read. What do you think?
amcandio
left a comment
There was a problem hiding this comment.
Looks good to me. It's worth evaluating using f strings rather than +, should be faster and nicer to read.
|
@amcandio switched that line to an f-string, agreed it reads better. @rossbar the literal_stringizer/destringizer path is a bit orthogonal here. Tuple labels are caught by this dedicated |
Right - my question is: if the user were to use the |
|
Right, and that's the part that caught me too. A supplied stringizer never actually sees a tuple label. The And this isn't really about serializing complex data the 'right' way. The fix doesn't change how the tuple renders at all, same |
|
Thanks @abdul-khaliq-khalid |
When a node or edge label is a tuple, generate_gml joins repr() of the elements directly into a quoted GML string without running it through escape() the way every other string value goes. A tuple element whose repr contains a double quote closes the string early, so a crafted label injects extra nodes, edges, or attributes into the output that another reader then parses back. The fix builds the tuple text and escapes it before emitting, so legitimate tuple labels are unchanged and quotes become the usual " entities. Added a round-trip regression test alongside the existing tuple-label and quoting tests.