Fix/rescue 227 regressions (#232)
* fix: restore regressions introduced by #227 #227 deleted build.rs (reverting #224's version-from-tag feature), removed DOM cycle guards in append_child/insert_before that prevent infinite loops on self-append/self-insert, dropped the CharacterData textContent fast-path, removed PI/Doctype Rust ops, and cut the env_allows_private_network() check from validate_fetch_url. Restored: - crates/obscura-cli/build.rs (version from tag/env) - OBSCURA_BUILD_VERSION in version string and banner - allow_private_network env var propagation in main.rs - append_child/insert_before self-cycle guards in tree.rs - textContent CharacterData fast-path in tree.rs - create_processing_instruction, create_doctype, pi_target, doctype_name, doctype_public_id ops in ops.rs - ProcessingInstruction branch in set_text_content op - env_allows_private_network() check in validate_fetch_url * fix(js): Europe/Berlin timezone, plugins iterator recursion Two bugs in the stealth bootstrap code from #227: - 'Europe/Germany' is not a valid IANA timezone; Intl.DateTimeFormat silently fell back to UTC. Changed to 'Europe/Berlin'. - plugins[Symbol.iterator] called this[Symbol.iterator]() recursively, blowing the stack on Array.from(navigator.plugins). Fixed to bind Array.prototype[Symbol.iterator] directly to the array.
This commit is contained in:
1 parent
990f2a63c8
commit
6b3cc1a686
5 files changed
+130
-6
No files matched your search
@@ -259,6 +259,7 @@ fn op_dom(state: &OpState, #[string] cmd: String, #[string] arg1: String, #[stri
|
||||
match &mut n.data {
|
||||
NodeData::Text { contents } => { *contents = arg2.clone(); }
|
||||
NodeData::Comment { contents } => { *contents = arg2.clone(); }
|
||||
NodeData::ProcessingInstruction { data, .. } => { *data = arg2.clone(); }
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
@@ -279,6 +280,47 @@ fn op_dom(state: &OpState, #[string] cmd: String, #[string] arg1: String, #[stri
|
||||
"create_comment_node" => {
|
||||
dom.new_node(NodeData::Comment { contents: arg1.clone() }).index().to_string()
|
||||
}
|
||||
"create_processing_instruction" => {
|
||||
// arg1 = target, arg2 = data
|
||||
dom.new_node(NodeData::ProcessingInstruction {
|
||||
target: arg1.clone(),
|
||||
data: arg2.clone(),
|
||||
}).index().to_string()
|
||||
}
|
||||
"create_doctype" => {
|
||||
// arg1 = name, arg2 = public_id. system_id stored only in the
|
||||
// JS wrapper since neither current WPT test reads it back from
|
||||
// the underlying tree.
|
||||
dom.new_node(NodeData::Doctype {
|
||||
name: arg1.clone(),
|
||||
public_id: arg2.clone(),
|
||||
system_id: String::new(),
|
||||
}).index().to_string()
|
||||
}
|
||||
"pi_target" => {
|
||||
let nid = arg1.parse::<u32>().unwrap_or(0);
|
||||
let val = dom.get_node(NodeId::new(nid)).and_then(|n| match &n.data {
|
||||
NodeData::ProcessingInstruction { target, .. } => Some(target.clone()),
|
||||
_ => None,
|
||||
}).unwrap_or_default();
|
||||
serde_json::to_string(&val).unwrap_or("\"\"".into())
|
||||
}
|
||||
"doctype_name" => {
|
||||
let nid = arg1.parse::<u32>().unwrap_or(0);
|
||||
let val = dom.get_node(NodeId::new(nid)).and_then(|n| match &n.data {
|
||||
NodeData::Doctype { name, .. } => Some(name.clone()),
|
||||
_ => None,
|
||||
}).unwrap_or_default();
|
||||
serde_json::to_string(&val).unwrap_or("\"\"".into())
|
||||
}
|
||||
"doctype_public_id" => {
|
||||
let nid = arg1.parse::<u32>().unwrap_or(0);
|
||||
let val = dom.get_node(NodeId::new(nid)).and_then(|n| match &n.data {
|
||||
NodeData::Doctype { public_id, .. } => Some(public_id.clone()),
|
||||
_ => None,
|
||||
}).unwrap_or_default();
|
||||
serde_json::to_string(&val).unwrap_or("\"\"".into())
|
||||
}
|
||||
"element_children" => {
|
||||
let nid = arg1.parse::<u32>().unwrap_or(0);
|
||||
let ids: Vec<i32> = dom.children(NodeId::new(nid)).iter()
|
||||
@@ -726,7 +768,7 @@ fn validate_fetch_url(url: &url::Url) -> Result<(), String> {
|
||||
));
|
||||
}
|
||||
|
||||
if scheme == "file" {
|
||||
if scheme == "file" || obscura_net::env_allows_private_network() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user