GNOME Bugzilla – Bug 779668
GST_DEBUG_BIN_TO_DOT: creates invalid .dot file when GstStructure parameter contains string with "@"
Last modified: 2018-11-03 12:39:50 UTC
When GST_DEBUG_BIN_TO_DOT_FILE dumps a bin containing an element with a GstStructure parameter, if the GstStructure contains a string value with "@" in it, the resulting .dot file is invalid. xdot gives the error "unexpected char '\'" I came across this bug when dumping the media-pipeline of a GStreamer RTSP server. The GstRtpSession sdes parameter is a GstStructure with a string parameter ("cname") that has an "@" symbol in it. I haven't investigated why this happens, but it looks like GstStructure does extra quoting on the output string when it contains "@", and then g_strescape() adds too many backslashes when escaping. Here's the invalid label line from the .dot file when the string doesn't contain "@": label="GstCapsFilter\nhi@\n[0]\nparent=(GstPipeline) pipeline\ncaps=application/x-rtp-source-sdes, cname=(string)user2341dqw"; And with "@": label="GstCapsFilter\ncapsfilter0\n[0]\nparent=(GstPipeline) pipeline\ncaps=application/x-rtp-source-sdes, cname=(string)\\\"user2341\\\\@dqw\\\""; According to the DOT language guide (http://www.graphviz.org/content/dot-language): "In quoted strings in DOT, the only escaped character is double-quote ("). That is, in quoted strings, the dyad \" is converted to "; all other characters are left unchanged. In particular, \\ remains \\"
Created attachment 347335 [details] Test program to output invalid .dot file
Created attachment 347336 [details] Sample invalid .dot file
Not sure why it's escaped that much. What are the actual caps there, do they include a literal '\'?
No, no backslashes in the caps: GstCaps *caps = gst_caps_new_simple ("application/x-rtp-source-sdes", "cname", G_TYPE_STRING, "user2341@dqw", NULL);
I tracked the escaping down to: gst/gst_private.h:#define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \ ((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \ ((c) == '.')) Adding @ fixes this, but this seems like the type of change to have random repercussions elsewhere. The string is escaped once in gst_string_wrap/gst_value_serialize_string, and then escaped in debug_dump_get_object_params, which treats the previous escaping backslashes as data.
I went back to this, and built a special escaping function which escaped only ", as the documentation dictates. However, that doesn't quite work, since escaping only " prevents properly escaping this: \" The first character is \, which stays unchanged as per dot docs. The second is a ", so is escaped as \". So the result is \\". Now, xdot chokes on this: label="GstCapsFilter\ncapsfilter0\n[0]\nparent=(GstPipeline) pipeline\ncaps=application/x-rtp-source-sdes, cname=(string)\\"user2341\\@dqw\\""; xdot gives: Error: <stdin>: syntax error in line 23 near '\' The label=... line seems well formed to me if only " gets escaped. I guess I could go find out in xdot's source what it does now.
Encoding \" seems impossible, as decoding can't give that AFAICT: \" will decode to " \\" will decode to \ and end the string \\\" will decode to \\"
Sorry, second one should read: \\" will decode to \\ and end the string This is due to \ not being escaped.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/224.