Improve server side html sanitization.
This commit is contained in:
16
server/src/bin/cleanhtml.rs
Normal file
16
server/src/bin/cleanhtml.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use std::fs;
|
||||
|
||||
use server::sanitize_html;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let mut args = std::env::args().skip(1);
|
||||
let src = args.next().expect("source not specified");
|
||||
let dst = args.next().expect("destination not specified");
|
||||
println!("Sanitizing {src} into {dst}");
|
||||
let bytes = fs::read(src)?;
|
||||
let html = String::from_utf8_lossy(&bytes);
|
||||
let html = sanitize_html(&html)?;
|
||||
fs::write(dst, html)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user