After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 779668 - GST_DEBUG_BIN_TO_DOT: creates invalid .dot file when GstStructure parameter contains string with "@"
GST_DEBUG_BIN_TO_DOT: creates invalid .dot file when GstStructure parameter c...
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-06 20:18 UTC by Brendan Shanks
Modified: 2018-11-03 12:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test program to output invalid .dot file (778 bytes, text/x-csrc)
2017-03-06 20:19 UTC, Brendan Shanks
Details
Sample invalid .dot file (1.50 KB, application/msword-template)
2017-03-06 20:19 UTC, Brendan Shanks
Details

Description Brendan Shanks 2017-03-06 20:18:59 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 \\"
Comment 1 Brendan Shanks 2017-03-06 20:19:23 UTC
Created attachment 347335 [details]
Test program to output invalid .dot file
Comment 2 Brendan Shanks 2017-03-06 20:19:47 UTC
Created attachment 347336 [details]
Sample invalid .dot file
Comment 3 Sebastian Dröge (slomo) 2017-03-07 09:59:53 UTC
Not sure why it's escaped that much. What are the actual caps there, do they include a literal '\'?
Comment 4 Brendan Shanks 2017-03-07 17:10:08 UTC
No, no backslashes in the caps:

  GstCaps *caps = gst_caps_new_simple
      ("application/x-rtp-source-sdes",
       "cname", G_TYPE_STRING,
       "user2341@dqw", NULL);
Comment 5 Vincent Penquerc'h 2017-03-17 10:40:22 UTC
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.
Comment 6 Vincent Penquerc'h 2017-03-30 14:37:29 UTC
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.
Comment 7 Vincent Penquerc'h 2017-03-31 08:58:41 UTC
Encoding \" seems impossible, as decoding can't give that AFAICT:

\" will decode to "
\\" will decode to \ and end the string
\\\" will decode to \\"
Comment 8 Vincent Penquerc'h 2017-03-31 09:10:04 UTC
Sorry, second one should read: \\" will decode to \\ and end the string

This is due to \ not being escaped.
Comment 9 GStreamer system administrator 2018-11-03 12:39:50 UTC
-- 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.