Filter SDP c lines
https://bugs.webkit.org/show_bug.cgi?id=199791

Reviewed by Eric Carlson.

Source/WebCore:

As discussed in https://github.com/rtcweb-wg/mdns-ice-candidates/issues/91,
use 0.0.0.0 for c lines when filtering the SDP.
Covered by updated test.

* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::filterSDP const):

LayoutTests:

* webrtc/datachannel/filter-ice-candidate.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247430 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8f55d72..cbf7b88 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,12 @@
+2019-07-15  Youenn Fablet  <youenn@apple.com>
+
+        Filter SDP c lines
+        https://bugs.webkit.org/show_bug.cgi?id=199791
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/datachannel/filter-ice-candidate.html:
+
 2019-07-14  Dean Jackson  <dino@apple.com>
 
         WebGL not supported on WKWebView on UIKit for Mac
diff --git a/LayoutTests/webrtc/datachannel/filter-ice-candidate.html b/LayoutTests/webrtc/datachannel/filter-ice-candidate.html
index 8e7b033..96937b7 100644
--- a/LayoutTests/webrtc/datachannel/filter-ice-candidate.html
+++ b/LayoutTests/webrtc/datachannel/filter-ice-candidate.html
@@ -24,8 +24,10 @@
                 return;
             }
             assert_equals(pc.localDescription.sdp.indexOf("a=candidate"), -1);
+            assert_true(pc.localDescription.sdp.indexOf("c=IN IP4 0.0.0.0") != -1 || pc.localDescription.sdp.indexOf("c=IN IP6 ::") != -1);
             if (counter === 0) {
                 pc.createOffer().then((offer) => {
+                    assert_true(offer.sdp.indexOf("c=IN IP4 0.0.0.0") != -1 || pc.localDescription.sdp.indexOf("c=IN IP6 ::") != -1);
                     assert_equals(offer.sdp.indexOf("a=candidate"), -1);
                     resolve();
                 });
@@ -54,10 +56,12 @@
                 counter++;
                 return;
             }
+            assert_true(pc.localDescription.sdp.indexOf("c=IN IP4 0.0.0.0") == -1 && pc.localDescription.sdp.indexOf("c=IN IP6 ::") === -1);
             assert_false(pc.localDescription.sdp.indexOf("a=candidate") === -1);
             if (counter !== 0) {
                 // Redoing an offer now that we have some candidates.
                 pc.createOffer().then((offer) => {
+                    assert_true(offer.sdp.indexOf("c=IN IP4 0.0.0.0") == -1 && pc.localDescription.sdp.indexOf("c=IN IP6 ::") === -1);
                     assert_false(offer.sdp.indexOf("a=candidate") === -1);
                     resolve();
                 });
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index af26e65..d2eb69a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2019-07-15  Youenn Fablet  <youenn@apple.com>
+
+        Filter SDP c lines
+        https://bugs.webkit.org/show_bug.cgi?id=199791
+
+        Reviewed by Eric Carlson.
+
+        As discussed in https://github.com/rtcweb-wg/mdns-ice-candidates/issues/91,
+        use 0.0.0.0 for c lines when filtering the SDP.
+        Covered by updated test.
+
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::filterSDP const):
+
 2019-07-15  Zalan Bujtas  <zalan@apple.com>
 
         naver.com: Video stops when tapping on the video to use buttons
diff --git a/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp b/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
index 21adefe..39c73a8 100644
--- a/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
+++ b/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
@@ -412,7 +412,11 @@
 
     StringBuilder filteredSDP;
     sdp.split('\n', [&filteredSDP](StringView line) {
-        if (!line.startsWith("a=candidate"))
+        if (line.startsWith("c=IN IP4"))
+            filteredSDP.append("c=IN IP4 0.0.0.0");
+        else if (line.startsWith("c=IN IP6"))
+            filteredSDP.append("c=IN IP6 ::");
+        else if (!line.startsWith("a=candidate"))
             filteredSDP.append(line);
         else if (line.find(" host ", 11) == notFound)
             filteredSDP.append(filterICECandidate(line.toString()));