Skip to content

Commit dcf64d4

Browse files
committed
avm2: Resolve relative URLs in NetConnection.connect() (close #23201)
Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
1 parent 4211e05 commit dcf64d4

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

core/src/avm2/globals/flash/net/net_connection.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,27 @@ pub fn connect<'gc>(
3131

3232
if let Some(url) = url {
3333
let url_lower = url.to_ascii_lowercase();
34-
35-
if url_lower.starts_with(WStr::from_units(b"http://"))
36-
|| url_lower.starts_with(WStr::from_units(b"https://"))
37-
{
34+
let is_already_http = url_lower.starts_with(WStr::from_units(b"http://"))
35+
|| url_lower.starts_with(WStr::from_units(b"https://"));
36+
37+
// Already-absolute HTTP(S) URLs are passed through unchanged. Other URLs
38+
// are resolved against the SWF's location so that relative HTTP(S) paths
39+
// reach Flash Remoting, matching URLLoader.load() behavior. Closes #23201.
40+
let http_url = if is_already_http {
41+
Some(url.to_string())
42+
} else {
43+
let url_string = url.to_string();
44+
activation
45+
.context
46+
.navigator
47+
.resolve_url(&url_string)
48+
.ok()
49+
.and_then(|u| matches!(u.scheme(), "http" | "https").then(|| u.to_string()))
50+
};
51+
52+
if let Some(http_url) = http_url {
3853
// HTTP(S) is for Flash Remoting, which is just POST requests to the URL.
39-
NetConnections::connect_to_flash_remoting(
40-
activation.context,
41-
connection,
42-
url.to_string(),
43-
);
54+
NetConnections::connect_to_flash_remoting(activation.context, connection, http_url);
4455
} else {
4556
avm2_stub_method!(
4657
activation,

0 commit comments

Comments
 (0)