Skip to content

Commit

Permalink
Don't symlink the escaper module (#355)
Browse files Browse the repository at this point in the history
The symlink doesn't work on Windows, and breaks NixOS builds.

Closes #343
  • Loading branch information
lambda-fairy authored Sep 18, 2022
1 parent 40dffec commit c13e1dc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions maud/src/escape.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!! PLEASE KEEP THIS IN SYNC WITH `maud_macros/src/escape.rs` !!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

extern crate alloc;

use alloc::string::String;
Expand Down
1 change: 0 additions & 1 deletion maud_macros/src/escape.rs

This file was deleted.

34 changes: 34 additions & 0 deletions maud_macros/src/escape.rs
Original file line number Diff line number Diff line change
@@ -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("&lt;"),
b'>' => output.push_str("&gt;"),
b'"' => output.push_str("&quot;"),
_ => 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, "&lt;script&gt;launchMissiles()&lt;/script&gt;");
}
}

0 comments on commit c13e1dc

Please sign in to comment.