webrtc, rtmp2: Fix parsing of userinfo in URI strings
authorNirbheek Chauhan <nirbheek@centricular.com>
Fri, 31 Jul 2020 20:42:21 +0000 (02:12 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Mon, 3 Aug 2020 18:12:50 +0000 (18:12 +0000)
While parsing the string, `gst_uri_from_string()` also unescapes the
userinfo. This is bad if your username contains a `:` character, since
we will then split the userinfo at the wrong location when parsing it.

To fix this, we can use the new `gst_uri_from_string_escaped()` API
that was added in
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/583

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/831

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1481>

ext/webrtc/gstwebrtcice.c
gst/rtmp2/gstrtmp2locationhandler.c

index 9a9630d..9b2cc66 100644 (file)
@@ -780,7 +780,7 @@ _clear_ice_stream (struct NiceStreamItem *item)
 static GstUri *
 _validate_turn_server (GstWebRTCICE * ice, const gchar * s)
 {
-  GstUri *uri = gst_uri_from_string (s);
+  GstUri *uri = gst_uri_from_string_escaped (s);
   const gchar *userinfo, *scheme;
   GList *keys = NULL, *l;
   gchar *user = NULL, *pass = NULL;
@@ -855,7 +855,7 @@ out:
 void
 gst_webrtc_ice_set_stun_server (GstWebRTCICE * ice, const gchar * uri_s)
 {
-  GstUri *uri = gst_uri_from_string (uri_s);
+  GstUri *uri = gst_uri_from_string_escaped (uri_s);
   const gchar *msg = "must be of the form stun://<host>:<port>";
 
   GST_DEBUG_OBJECT (ice, "setting stun server, %s", uri_s);
index 49c83bd..7c79c79 100644 (file)
@@ -165,7 +165,7 @@ uri_handler_set_uri (GstURIHandler * handler, const gchar * string,
 
   {
     gchar *string_without_path = g_strndup (string, path_sep - string);
-    uri = gst_uri_from_string (string_without_path);
+    uri = gst_uri_from_string_escaped (string_without_path);
     g_free (string_without_path);
   }