mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Reject stun urls with query parameters
for consistency with Chromium behavior, in particular stun:host?transport=udp gets rejected. BUG=chromium:1385735 Change-Id: I85a141ecf72480bfa09d8354d6dcaef8ca0cdcff Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299943 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Guido Urdaneta <guidou@webrtc.org> Commit-Queue: Philipp Hancke <phancke@microsoft.com> Cr-Commit-Position: refs/heads/main@{#39916}
This commit is contained in:
parent
7aa6a72dc6
commit
ff6cd53303
2 changed files with 11 additions and 0 deletions
|
@ -220,6 +220,15 @@ RTCError ParseIceServerUrl(
|
||||||
// GetServiceTypeAndHostnameFromUri should never give an empty hoststring
|
// GetServiceTypeAndHostnameFromUri should never give an empty hoststring
|
||||||
RTC_DCHECK(!hoststring.empty());
|
RTC_DCHECK(!hoststring.empty());
|
||||||
|
|
||||||
|
// stun with ?transport (or any ?) is not valid.
|
||||||
|
if ((service_type == ServiceType::STUN ||
|
||||||
|
service_type == ServiceType::STUNS) &&
|
||||||
|
tokens.size() > 1) {
|
||||||
|
LOG_AND_RETURN_ERROR(
|
||||||
|
RTCErrorType::SYNTAX_ERROR,
|
||||||
|
"ICE server parsing failed: Invalid stun url with query parameters");
|
||||||
|
}
|
||||||
|
|
||||||
int default_port = kDefaultStunPort;
|
int default_port = kDefaultStunPort;
|
||||||
if (service_type == ServiceType::TURNS) {
|
if (service_type == ServiceType::TURNS) {
|
||||||
default_port = kDefaultStunTlsPort;
|
default_port = kDefaultStunTlsPort;
|
||||||
|
|
|
@ -188,6 +188,8 @@ TEST_F(IceServerParsingTest, ParseHostnameAndPort) {
|
||||||
EXPECT_FALSE(ParseUrl("stun:/hostname")); // / is not allowed
|
EXPECT_FALSE(ParseUrl("stun:/hostname")); // / is not allowed
|
||||||
EXPECT_FALSE(ParseUrl("stun:?hostname")); // ? is not allowed
|
EXPECT_FALSE(ParseUrl("stun:?hostname")); // ? is not allowed
|
||||||
EXPECT_FALSE(ParseUrl("stun:#hostname")); // # is not allowed
|
EXPECT_FALSE(ParseUrl("stun:#hostname")); // # is not allowed
|
||||||
|
// STUN explicitly forbids query parameters.
|
||||||
|
EXPECT_FALSE(ParseUrl("stun:hostname?transport=udp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test parsing the "?transport=xxx" part of the URL.
|
// Test parsing the "?transport=xxx" part of the URL.
|
||||||
|
|
Loading…
Reference in a new issue