MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / escape_script_json

Function escape_script_json

atomic-cli/src/commands/triage/output.rs:513–517  ·  view source on GitHub ↗

Escape a JSON payload for safe embedding inside a ` ` element: the `<`, `>`, and `&` bytes are rewritten to their `\u00XX` JSON escapes so the literal sequence ` ` (and `<!--`) can never terminate the tag.

(s: &str)

Source from the content-addressed store, hash-verified

511/// `<`, `>`, and `&` bytes are rewritten to their `\u00XX` JSON escapes so the
512/// literal sequence `</script>` (and `<!--`) can never terminate the tag.
513fn escape_script_json(s: &str) -> String {
514 s.replace('&', "\\u0026")
515 .replace('<', "\\u003c")
516 .replace('>', "\\u003e")
517}
518
519const FILTER_SCRIPT: &str = r#"function filterFindings(sev){
520 document.querySelectorAll('.finding').forEach(function(el){

Callers 1

render_htmlFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected