mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-30 07:42:32 +00:00
parse: don't unescape inside quotes
Escaped characters inside quoted strings are supposed to be unescaped by deserialization functions, not by parsing functions. https://bugzilla.gnome.org/show_bug.cgi?id=648025
This commit is contained in:
parent
f07b637d86
commit
f450817d7f
2 changed files with 23 additions and 1 deletions
|
@ -69,17 +69,24 @@ static inline void
|
|||
gst_parse_unescape (gchar *str)
|
||||
{
|
||||
gchar *walk;
|
||||
gboolean in_quotes;
|
||||
|
||||
g_return_if_fail (str != NULL);
|
||||
|
||||
walk = str;
|
||||
in_quotes = FALSE;
|
||||
|
||||
while (*walk) {
|
||||
if (*walk == '\\') {
|
||||
if (*walk == '\\' && !in_quotes) {
|
||||
walk++;
|
||||
/* make sure we don't read beyond the end of the string */
|
||||
if (*walk == '\0')
|
||||
break;
|
||||
} else if (*walk == '"' && (!in_quotes || (in_quotes
|
||||
&& (*(walk - 1) != '\\')))) {
|
||||
/* don't unescape inside quotes and don't switch
|
||||
* state with escaped quoted inside quotes */
|
||||
in_quotes = !in_quotes;
|
||||
}
|
||||
*str = *walk;
|
||||
str++;
|
||||
|
|
|
@ -145,6 +145,8 @@ GST_END_TEST;
|
|||
#define PIPELINE11 "fakesink silent=true name = sink identity silent=true name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink."
|
||||
#define PIPELINE12 "file:///tmp/test.file ! fakesink silent=true"
|
||||
#define PIPELINE13 "fakesrc ! file:///tmp/test.file"
|
||||
#define PIPELINE14 "capsfilter caps=application/x-rtp,sprop-parameter-sets=(string)\"x\\,x\""
|
||||
#define PIPELINE15 "capsfilter caps=application/x-rtp,sprop-parameter-sets=(string)\"x\\\"x\\,x\""
|
||||
|
||||
GST_START_TEST (test_launch_lines2)
|
||||
{
|
||||
|
@ -285,6 +287,19 @@ GST_START_TEST (test_launch_lines2)
|
|||
* This should warn, but ignore the error and carry on */
|
||||
cur = setup_pipeline ("( filesrc blocksize=4 location=/dev/null @ )");
|
||||
gst_object_unref (cur);
|
||||
|
||||
/**
|
||||
* Checks if characters inside quotes are not escaped.
|
||||
*/
|
||||
cur = setup_pipeline (PIPELINE14);
|
||||
gst_object_unref (cur);
|
||||
|
||||
/**
|
||||
* Checks if escaped quotes inside quotes are not treated as end string quotes.
|
||||
* This would make the rest of characters to be escaped incorrectly.
|
||||
*/
|
||||
cur = setup_pipeline (PIPELINE15);
|
||||
gst_object_unref (cur);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
|
Loading…
Reference in a new issue