Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the url spec to parse ice server urls (Take 2). #2853

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions amendments.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
"type": "correction",
"status": "candidate",
"id": 6
},
{
"description": "Use the url spec to parse ice server urls",
"pr": 2853,
"type": "correction",
"status": "candidate",
"id": 33
}
],
"rtcicegatheringstate-description": [
Expand Down
79 changes: 45 additions & 34 deletions webrtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -3063,7 +3063,7 @@ <h4>
<li>
<p>
If <var>urls</var> is empty, [= exception/throw =] a
{{SyntaxError}}.
"{{SyntaxError}}" {{DOMException}}.
</p>
</li>
<li>
Expand All @@ -3073,44 +3073,55 @@ <h4>
</p>
<ol>
<li>
<p>
Parse the <var>url</var> using the generic URI syntax
defined in [[!RFC3986]] and obtain the <var>scheme
name</var>. If the parsing based on the syntax
defined in [[!RFC3986]] fails, [= exception/throw =]
a {{SyntaxError}}. If the <var>scheme name</var> is
not implemented by the browser [= exception/throw =]
a {{NotSupportedError}}. If <var>scheme name</var> is
<code class="scheme">turn</code> or <code class=
"scheme">turns</code>, and parsing the <var>url</var>
using the syntax defined in [[!RFC7065]] fails, [=
exception/throw =] a {{SyntaxError}}. If <var>scheme
name</var> is <code class="scheme">stun</code> or
<code class="scheme">stuns</code>, and parsing the
<var>url</var> using the syntax defined in
[[!RFC7064]] fails, [= exception/throw =] a
{{SyntaxError}}.
</p>
<p>Let <var>parsedURL</var> be the result of
<a data-cite="!url#concept-url-parser">parsing</a>
<var>url</var>.</p>
</li>
<li>
<p>
If <var>scheme name</var> is <code class=
"scheme">turn</code> or <code class=
"scheme">turns</code>, and either of
<var>server</var>.{{RTCIceServer/username}} or
<var>server</var>.{{RTCIceServer/credential}} are
omitted, then [= exception/throw =] an
{{InvalidAccessError}}.
</p>
<p>If any of the following conditions apply, then [=exception/throw=] a
"{{SyntaxError}}" {{DOMException}}:</p>
<ul>
<li><var>parsedURL</var> is failure</li>
<li><var>parsedURL</var>'s [=url/scheme=] is neither `"stun"`,
`"stuns"`, `"turn"`, nor `"turns"`</li>
<li><var>parsedURL</var> does not have an [=url/opaque path=]</li>
<li><var>parsedURL</var>'s' [=url/fragment=] is non-null</li>
<li><var>parsedURL</var>'s' [=url/scheme=] is `"stun"` or `"stuns"`,
and <var>parsedURL</var>'s' [=url/query=] is non-null</li>
</ul>
</li>
<li>
<p>If <var>parsedURL</var>'s [=url/scheme=] is not implemented by the
user agent, then [=exception/throw=] a {{NotSupportedError}}.</p>
</li>
<li>
<p>Let <var>hostAndPortURL</var> be result of
<a data-cite="!url#concept-url-parser">parsing</a> the concatenation of
`"https://"` and <var>parsedURL</var>'s [=url/path=].</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a decidedldy odd way of parsing the arguments to the URL.
It assumes that 7064 and 7065 are completely consistent with the relevant parts of the URL spec. I'd prefer to have the URL spec learn to parse TURN URLs - @annevk may have opinions on the proper way to do this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of whatwg/url#767? I think that's essentially the missing piece to be able to define a "stun/turn URL processor", right?

And essentially that comes down to a sound way of separating the port from the host.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annevk may have opinions on the proper way to do this.

This is based on https://bugs.webkit.org/show_bug.cgi?id=164508#c10 from him.

I'd prefer to have the URL spec learn to parse TURN URLs

This PR moves more of the logic there, which seems a step in the right direction.

Specifically: RFC 7064 section 3.1 says: "<host> and <port> are specified in [RFC3986]." and the URL spec goals say: "Align RFC 3986 and RFC 3987 with contemporary implementations and obsolete the RFCs in the process"

</li>
<li>
<p>If <var>hostAndPortURL</var> is failure, then [=exception/throw=] a
"{{SyntaxError}}" {{DOMException}}.</p>
<p class="note">For "stun" and "stuns" schemes, this validates
[[!RFC7064]] section 3.1.<br>
For "turn" and "turns" schemes, this and the steps below validate
[[!RFC7065]] section 3.1.</p>
</li>
<li>
<p>If <var>parsedURL</var>'s [=url/query=] is non-null, run the following
sub-steps:</p>
<ol>
<li><p>TODO: validate ?transport=udp|tcp</p></li>
</ol>
</li>
<li>
<p>
If <var>scheme name</var> is <code class=
"scheme">turn</code> or <code class=
"scheme">turns</code>, and
<var>server</var>.{{RTCIceServer/credential}} is not
a <span class="idlMemberType">DOMString</span>, then
[= exception/throw =] an {{InvalidAccessError}}.
If <var>parsedURL</var>'s' [=url/scheme=] is <code>"turn"</code> or
<code>"turns"</code>, and either of
<var>server</var>.{{RTCIceServer/username}} or
<var>server</var>.{{RTCIceServer/credential}} do
[=map/exist|not exist=], then [= exception/throw =] an
{{InvalidAccessError}}.
</p>
</li>
</ol>
Expand Down
2 changes: 1 addition & 1 deletion webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var respecConfig = {
}

],
xref: ["dom", "hr-time", "webidl", "html", "mediacapture-streams", "fileapi", "webrtc-stats", "websockets", "xhr", "infra"],
xref: ["dom", "hr-time", "webidl", "html", "mediacapture-streams", "fileapi", "webrtc-stats", "websockets", "xhr", "infra", "url"],
preProcess: [
highlightTests,
markTestableAssertions,
Expand Down