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:
SGavrl authored and GitHub committed 2026-06-03 18:16:20 +00:00
1 parent 990f2a63c8
commit 6b3cc1a686
5 files changed
+130 -6

No files matched your search

+14 -3
View File
@@ -10,7 +10,7 @@ use tokio::time::{timeout, Duration};
#[derive(Parser)]
#[command(
name = "obscura",
version = env!("CARGO_PKG_VERSION"),
version = env!("OBSCURA_BUILD_VERSION"),
about = "Obscura - A lightweight headless browser for web scraping and automation",
)]
struct Args {
@@ -189,9 +189,9 @@ fn print_banner(port: u16) {
| |__| | |_) \__ \ (__| |_| | | | (_| |
\____/|_.__/|___/\___|\__,_|_| \__,_|
Headless Browser v0.1.6
Headless Browser v{}
CDP server: ws://127.0.0.1:{}/devtools/browser
"#, port);
"#, env!("OBSCURA_BUILD_VERSION"), port);
}
fn select_log_filter(verbose: bool, quiet: bool) -> &'static str {
@@ -263,6 +263,17 @@ async fn main() -> anyhow::Result<()> {
tracing::debug!("V8 flags: {}", v8_flags);
obscura_js::set_v8_flags(&v8_flags);
// The js-side fetch path (op_fetch_url) reads OBSCURA_ALLOW_PRIVATE_NETWORK
// directly for its SSRF gate. Mirror the CLI flag into the env var so
// iframe loads and JS fetch() see the same policy the http_client layer
// already uses (issue #33).
if args.allow_private_network {
// SAFETY: set_var is unsafe in newer rustc; this runs before any
// spawned thread inspects the env, so it's effectively single
// threaded at this point.
unsafe { std::env::set_var("OBSCURA_ALLOW_PRIVATE_NETWORK", "1"); }
}
let global_proxy = args.proxy.clone();
match args.command {