mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
16 lines
616 B
Rust
16 lines
616 B
Rust
/// XSS — negative fixture.
|
|
///
|
|
/// Safe function: HTML-escapes user input before embedding in output.
|
|
/// Expected verdict: NotConfirmed (XSS payload is escaped; no raw script tag in output).
|
|
/// Cap: HTML_ESCAPE Entry: `run(payload: &str)`
|
|
pub fn run(payload: &str) {
|
|
// Safe: escape all HTML special characters before rendering.
|
|
let escaped = payload
|
|
.replace('&', "&")
|
|
.replace('<', "<")
|
|
.replace('>', ">")
|
|
.replace('"', """)
|
|
.replace('\'', "'");
|
|
let html = format!("<div class='comment'>{}</div>", escaped);
|
|
println!("{}", html);
|
|
}
|