summaryrefslogtreecommitdiffstats
path: root/netwerk/base/mozurl/src/lib.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /netwerk/base/mozurl/src/lib.rs
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/base/mozurl/src/lib.rs')
-rw-r--r--netwerk/base/mozurl/src/lib.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/netwerk/base/mozurl/src/lib.rs b/netwerk/base/mozurl/src/lib.rs
index 21be5f7e8b..ac33f0f8a8 100644
--- a/netwerk/base/mozurl/src/lib.rs
+++ b/netwerk/base/mozurl/src/lib.rs
@@ -214,7 +214,10 @@ pub extern "C" fn mozurl_real_port(url: &MozURL) -> i32 {
#[no_mangle]
pub extern "C" fn mozurl_host_port(url: &MozURL) -> SpecSlice {
- (&url[Position::BeforeHost..Position::BeforePath]).into()
+ if url.port().is_some() {
+ return (&url[Position::BeforeHost..Position::BeforePath]).into();
+ }
+ url.host_str().unwrap_or("").into()
}
#[no_mangle]
@@ -436,6 +439,11 @@ pub extern "C" fn mozurl_set_hostname(url: &mut MozURL, host: &nsACString) -> ns
#[no_mangle]
pub extern "C" fn mozurl_set_port_no(url: &mut MozURL, new_port: i32) -> nsresult {
debug_assert_mut!(url);
+
+ if new_port > u16::MAX as i32 {
+ return NS_ERROR_UNEXPECTED;
+ }
+
if url.cannot_be_a_base() {
return NS_ERROR_MALFORMED_URI;
}