* 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.
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
use std::env;
|
|
|
|
fn env_value(name: &str) -> Option<String> {
|
|
env::var(name)
|
|
.ok()
|
|
.map(|value| value.trim().to_string())
|
|
.filter(|value| !value.is_empty())
|
|
}
|
|
|
|
fn normalize_version(version: String) -> String {
|
|
version.strip_prefix('v').unwrap_or(&version).to_string()
|
|
}
|
|
|
|
fn github_tag_version() -> Option<String> {
|
|
if env_value("GITHUB_REF_TYPE").as_deref() == Some("tag") {
|
|
return env_value("GITHUB_REF_NAME").map(normalize_version);
|
|
}
|
|
|
|
env_value("GITHUB_REF")
|
|
.and_then(|value| value.strip_prefix("refs/tags/").map(str::to_owned))
|
|
.map(normalize_version)
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-env-changed=OBSCURA_VERSION");
|
|
println!("cargo:rerun-if-env-changed=GITHUB_REF_TYPE");
|
|
println!("cargo:rerun-if-env-changed=GITHUB_REF_NAME");
|
|
println!("cargo:rerun-if-env-changed=GITHUB_REF");
|
|
|
|
let version = env_value("OBSCURA_VERSION")
|
|
.map(normalize_version)
|
|
.or_else(github_tag_version)
|
|
.unwrap_or_else(|| env::var("CARGO_PKG_VERSION").expect("Cargo sets CARGO_PKG_VERSION"));
|
|
|
|
println!("cargo:rustc-env=OBSCURA_BUILD_VERSION={version}");
|
|
}
|