mirror of
https://github.com/storytold/craft-anything.git
synced 2026-11-19 14:00:52 +01:00
Replays #591–#596. The HTML scanner reads rel token lists, decodes asset URLs once, keeps script and title text through lookalike closing tags, and skips raw-text elements, markup inside attribute values and custom tag names. Co-authored-by: Afloat <132809511+Afloat16@users.noreply.github.com>
13 lines
568 B
Rust
13 lines
568 B
Rust
use craft_anything_js::html::scan_html;
|
|
|
|
#[test]
|
|
fn regression_text_elements_do_not_invent_script_dependencies() {
|
|
for tag in ["style", "textarea", "xmp", "iframe", "noembed", "noframes"] {
|
|
let page = format!("<{tag}><script src='ghost.js'></script></{tag}><script src='real.js'></script>");
|
|
let f = scan_html(&page);
|
|
assert_eq!(f.scripts.len(), 1, "{tag}: {:?}", f.scripts);
|
|
assert_eq!(f.scripts[0].src.as_deref(), Some("real.js"));
|
|
}
|
|
assert!(scan_html("<plaintext><script src='ghost.js'></script>").scripts.is_empty());
|
|
}
|