Skip to content

Commit

Permalink
Merge pull request #196 from notriddle/notriddle/processing-instructi…
Browse files Browse the repository at this point in the history
…on-test-case

Add a regression test for `<?xml-stylesheet?>`
  • Loading branch information
notriddle authored Mar 31, 2024
2 parents 6a1f856 + 429b1c0 commit a6b0de4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3638,6 +3638,22 @@ mod test {
);
}

#[test]
fn xml_processing_instruction() {
// https://blog.slonser.info/posts/dompurify-node-type-confusion/
let fragment = r##"<svg><?xml-stylesheet src='slonser' ?></svg>"##;
let result = String::from(Builder::new().clean(fragment));
assert_eq!(result.to_string(), "");

let fragment = r##"<svg><?xml-stylesheet src='slonser' ?></svg>"##;
let result = String::from(Builder::new().add_tags(&["svg"]).clean(fragment));
assert_eq!(result.to_string(), "<svg></svg>");

let fragment = r##"<svg><?xml-stylesheet ><img src=x onerror="alert('Ammonia bypassed!!!')"> ?></svg>"##;
let result = String::from(Builder::new().add_tags(&["svg"]).clean(fragment));
assert_eq!(result.to_string(), "<svg></svg><img src=\"x\"> ?&gt;");
}

#[test]
fn generic_attribute_prefixes() {
let prefix_data = ["data-"];
Expand Down

0 comments on commit a6b0de4

Please sign in to comment.