Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(iframe): encode src queries with the owner document charset
ldm0e30f21d4bed1
diff --git a/moli-renderer-v8/src/native_bridge/context_host/child_frames/discovery.rs b/moli-renderer-v8/src/native_bridge/context_host/child_frames/discovery.rsindex b67dfe68a..10c829ac1 100644--- a/moli-renderer-v8/src/native_bridge/context_host/child_frames/discovery.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/child_frames/discovery.rs@@ -1,5 +1,6 @@use super::*;use crate::dom::native::Node;+use crate::native_bridge::element::parse_url_with_document_query_encoding;#[derive(Clone, Copy, Debug, PartialEq, Eq)]enum ChildFrameOwnerElementKind {@@ -144,6 +145,12 @@ impl JsContextHost {.unwrap_or_else(|_| Url::parse("about:blank").expect("static about:blank should parse"))}+ fn resolve_child_frame_owner_attribute_url(&self, handle: DomHandle, raw: &str) -> Url {+ let base = self.document_base_url_for_child_context(handle);+ parse_url_with_document_query_encoding(self, handle, &base, raw)+ .unwrap_or_else(|_| Url::parse("about:blank").expect("static about:blank should parse"))+ }+pub(in crate::native_bridge::context_host) fn child_browsing_context_bootstrap_for_handle(&self,handle: DomHandle,@@ -184,7 +191,7 @@ impl JsContextHost {.then_some(ChildBrowsingContextBootstrap::AboutBlank);}- let url = self.resolve_child_browsing_context_url(handle, raw_url);+ let url = self.resolve_child_frame_owner_attribute_url(handle, raw_url);if !kind.always_hosts_document()&& (self.embedded_content_is_inside_media_element(handle)|| !self.embedded_content_selects_nested_document(handle, raw_url, &url))diff --git a/moli-renderer-v8/src/native_bridge/context_host/mod.rs b/moli-renderer-v8/src/native_bridge/context_host/mod.rsindex 5c2ca44fd..2895814c4 100644--- a/moli-renderer-v8/src/native_bridge/context_host/mod.rs+++ b/moli-renderer-v8/src/native_bridge/context_host/mod.rs@@ -1197,6 +1197,15 @@ impl fmt::Debug for JsContextHost {#[cfg(test)]impl JsContextHost {+ pub(crate) fn child_browsing_context_attribute_bootstrap_for_test(+ &self,+ handle: crate::document_runtime::DomHandle,+ ) -> Option<ChildBrowsingContextBootstrap> {+ self.child_browsing_contexts+ .get(&handle)+ .map(|entry| entry.attribute_bootstrap().clone())+ }+pub(crate) fn child_browsing_context_pending_live_navigation_for_test(&self,handle: crate::document_runtime::DomHandle,diff --git a/moli-renderer-v8/src/native_bridge/element.rs b/moli-renderer-v8/src/native_bridge/element.rsindex f9ac0af2c..c3a961ba0 100644--- a/moli-renderer-v8/src/native_bridge/element.rs+++ b/moli-renderer-v8/src/native_bridge/element.rs@@ -656,6 +656,7 @@ pub(super) use tree_mutation::{node_insert_adjacent_element_callback, node_insert_adjacent_html_callback,node_insert_adjacent_node_callback, node_insert_adjacent_text_callback,};+pub(in crate::native_bridge) use url_attributes::parse_url_with_document_query_encoding;pub(super) use url_attributes::update_iframe_snapshot_navigation;use url_attributes::{disconnected_iframe_can_materialize_detached_content, iframe_has_inactive_child_context,diff --git a/moli-renderer-v8/src/native_bridge/element/url_attributes.rs b/moli-renderer-v8/src/native_bridge/element/url_attributes.rsindex a91a2edf6..aada64160 100644--- a/moli-renderer-v8/src/native_bridge/element/url_attributes.rs+++ b/moli-renderer-v8/src/native_bridge/element/url_attributes.rs@@ -1,6 +1,7 @@mod helpers;mod iframe;+pub(in crate::native_bridge) use self::helpers::parse_url_with_document_query_encoding;pub(super) use self::helpers::{parsed_url_like_attribute, resolve_url_like_attribute, set_resolved_url_attribute,should_block_dangling_markup_subresource,diff --git a/moli-renderer-v8/src/native_bridge/element/url_attributes/helpers.rs b/moli-renderer-v8/src/native_bridge/element/url_attributes/helpers.rsindex 6d5b6ea52..71037a661 100644--- a/moli-renderer-v8/src/native_bridge/element/url_attributes/helpers.rs+++ b/moli-renderer-v8/src/native_bridge/element/url_attributes/helpers.rs@@ -61,7 +61,7 @@ pub(in crate::native_bridge::element) fn should_block_dangling_markup_subresourc.any(|byte| matches!(byte, b'\r' | b'\n' | b'\t'))}-fn parse_url_with_document_query_encoding(+pub(in crate::native_bridge) fn parse_url_with_document_query_encoding(runtime: &JsContextHost,handle: DomHandle,base: &Url,diff --git a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rs b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rsindex 22aa33169..45ec89b13 100644--- a/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rs+++ b/moli-renderer-v8/src/script_vm/tests/dom_elements/dom_surface/extracted/frame_navigation_and_history.rs@@ -2688,3 +2688,48 @@ fn dynamic_about_blank_iframe_navigation_uses_origin_referrer() {r#"{"referrer":"http://dynamic-about-blank-referrer.test/","loads":1,"href":"about:blank","historyLength":1}"#);}++#[test]+fn iframe_src_navigation_uses_owner_document_encoding_for_query() {+ let mut vm = new_storage_test_vm("https://iframe-src-encoding.test/page.html");+ vm.document_runtime+ .set_document_character_set("windows-1252");++ let reflected_src = vm+ .eval(+ r#"+(() => {+ const frame = document.createElement("iframe");+ frame.id = "encoded-src-frame";+ frame.src = "resources/frame.html?\u00DF";+ (document.body || document.documentElement || document).appendChild(frame);+ return frame.src;+})()+"#,+ )+ .expect("legacy-encoded iframe src setup should evaluate");+ assert_eq!(+ reflected_src,+ "https://iframe-src-encoding.test/resources/frame.html?%DF"+ );++ let child_handle = vm+ .document_runtime+ .dom_host()+ .element_handle_by_id("encoded-src-frame")+ .expect("encoded src iframe owner");+ let attribute_bootstrap = vm+ ._context_host+ .borrow()+ .child_browsing_context_attribute_bootstrap_for_test(child_handle)+ .expect("encoded src attribute bootstrap should exist");+ assert!(+ matches!(+ attribute_bootstrap,+ crate::native_bridge::ChildBrowsingContextBootstrap::Url(ref url)+ if url.as_str()+ == "https://iframe-src-encoding.test/resources/frame.html?%DF"+ ),+ "iframe navigation must use the same owner-document encoding as its reflected src: {attribute_bootstrap:?}"+ );+}