Bug 879654: Tolerate '?transport=udp' by stripping it r=jesup
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 05 Jun 2013 15:44:48 -0400
changeset 145810 0a4e35605fa35b077b67708ad74a5e47906ff722
parent 145809 026a5847ccd03918e3a2aa1171cbaccfb88def15
child 145811 0a613c3c8a01469ed71cef015cc57a1cef1aacf9
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs879654
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 879654: Tolerate '?transport=udp' by stripping it r=jesup
dom/media/tests/mochitest/test_peerConnection_bug825703.html
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- a/dom/media/tests/mochitest/test_peerConnection_bug825703.html
+++ b/dom/media/tests/mochitest/test_peerConnection_bug825703.html
@@ -49,17 +49,17 @@
     makePC({ iceServers: [{ url:"" }] }, false);
 
     makePC({ iceServers: [{ url:"http:0.0.0.0" }] }, false);
 
     makePC({ iceServers: [
                 { url:"stun:0.0.0.0" },
                 { url:"stuns:x.net", foo:"" },
                 { url:"turn:[::192.9.5.5]:42", username:"p", credential:"p" },
-                { url:"turns:x.org:42", username:"p", credential:"p" }
+                { url:"turns:x.org:42?transport=udp", username:"p", credential:"p" }
                 ]}, true);
 
     pcs = null;
     SimpleTest.finish();
   });
 </script>
 </pre>
 </body>
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -394,17 +394,18 @@ PeerConnectionImpl::CreateRemoteSourceSt
 
   return NS_OK;
 }
 
 /**
  * In JS, an RTCConfiguration looks like this:
  *
  * { "iceServers": [ { url:"stun:23.21.150.121" },
- *                   { url:"turn:turn.example.org", credential:"mypass", "username"} ] }
+ *                   { url:"turn:turn.example.org?transport=udp",
+ *                     username: "jib", credential:"mypass"} ] }
  *
  * This function converts an already-validated jsval that looks like the above
  * into an IceConfiguration object.
  */
 nsresult
 PeerConnectionImpl::ConvertRTCConfiguration(const JS::Value& aSrc,
                                             IceConfiguration *aDst,
                                             JSContext* aCx)
@@ -444,16 +445,23 @@ PeerConnectionImpl::ConvertRTCConfigurat
     int32_t port;
     nsAutoCString host;
     {
       uint32_t hostPos;
       int32_t hostLen;
       nsAutoCString path;
       rv = url->GetPath(path);
       NS_ENSURE_SUCCESS(rv, rv);
+
+      // Tolerate '?transport=udp' by stripping it.
+      int32_t questionmark = path.FindChar('?');
+      if (questionmark >= 0) {
+        path.SetLength(questionmark);
+      }
+
       rv = net_GetAuthURLParser()->ParseAuthority(path.get(), path.Length(),
                                                   nullptr,  nullptr,
                                                   nullptr,  nullptr,
                                                   &hostPos,  &hostLen, &port);
       NS_ENSURE_SUCCESS(rv, rv);
       if (!hostLen) {
         return NS_ERROR_FAILURE;
       }