Don't symlink the escaper module (#355)
The symlink doesn't work on Windows, and breaks NixOS builds. Closes #343
This commit is contained in:
parent
40dffecd5d
commit
c13e1dcc48
2 changed files with 38 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
// !!!!! PLEASE KEEP THIS IN SYNC WITH `maud_macros/src/escape.rs` !!!!!
|
||||||
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../maud/src/escape.rs
|
|
34
maud_macros/src/escape.rs
Normal file
34
maud_macros/src/escape.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
// !!!!!!!! PLEASE KEEP THIS IN SYNC WITH `maud/src/escape.rs` !!!!!!!!!
|
||||||
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::string::String;
|
||||||
|
|
||||||
|
pub fn escape_to_string(input: &str, output: &mut String) {
|
||||||
|
for b in input.bytes() {
|
||||||
|
match b {
|
||||||
|
b'&' => output.push_str("&"),
|
||||||
|
b'<' => output.push_str("<"),
|
||||||
|
b'>' => output.push_str(">"),
|
||||||
|
b'"' => output.push_str("""),
|
||||||
|
_ => unsafe { output.as_mut_vec().push(b) },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
use super::escape_to_string;
|
||||||
|
use alloc::string::String;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let mut s = String::new();
|
||||||
|
escape_to_string("<script>launchMissiles()</script>", &mut s);
|
||||||
|
assert_eq!(s, "<script>launchMissiles()</script>");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue