-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't symlink the escaper module (#355)
The symlink doesn't work on Windows, and breaks NixOS builds. Closes #343
- Loading branch information
1 parent
40dffec
commit c13e1dc
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("<"), | ||
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>"); | ||
} | ||
} |