Skip to content

Commit

Permalink
bugfix: webtransport_is_available_with_cert_hashes() now detects if i…
Browse files Browse the repository at this point in the history
…n a buggy Firefox version
  • Loading branch information
UkoeHB committed Jan 15, 2025
1 parent 7606c38 commit 9d10fbc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.1.1 - 01/15/25

- Fix `webtransport_is_available_with_cert_hashes()` to detect if in a buggy Firefox version. See https://phabricator.services.mozilla.com/D231479

## 0.1.0 - 12/23/24

- Update `renet2` sub-crate dependencies.
Expand Down
2 changes: 2 additions & 0 deletions renet2_netcode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ features = [
"Event",
"ErrorEvent",
"BinaryType",
"Window",
"Navigator"
]

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn webtransport_is_available() -> bool {
///
/// See [`webtransport_is_available`] if you don't care about cert hashes.
pub fn webtransport_is_available_with_cert_hashes() -> bool {
webtransport_is_available_impl(true)
!buggy_firefox_version() && webtransport_is_available_impl(true)
}

fn webtransport_is_available_impl(with_cert_hashes: bool) -> bool {
Expand All @@ -32,3 +32,23 @@ fn webtransport_is_available_impl(with_cert_hashes: bool) -> bool {
// - https://developer.mozilla.org/en-US/docs/Web/API/WebTransport/WebTransport#exceptions
WebTransport::new_with_options(url.as_str(), &config.wt_options()).is_ok()
}

// Note: this test can fail if the user modified their firefox user-agent string from the default.
fn buggy_firefox_version() -> bool {
// Firefox workaround for bug in v133-?.
// TODO: update this to filter on the correct version range when the bug is fixed
if let Some(window) = web_sys::window() {
if let Ok(user_agent_str) = window.navigator().user_agent() {
if let Some((_, firefox)) = user_agent_str.split_once("Firefox/") {
if let Some(version) = firefox.get(0..=4) {
if let Ok(version) = version.parse::<f32>() {
if version >= 133.0 {
return true;
}
}
}
}
}
}
false
}

0 comments on commit 9d10fbc

Please sign in to comment.