File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change
1
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
+ // !!!!! PLEASE KEEP THIS IN SYNC WITH `maud_macros/src/escape.rs` !!!!!
3
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4
+
1
5
extern crate alloc;
2
6
3
7
use alloc:: string:: String ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
+ // !!!!!!!! PLEASE KEEP THIS IN SYNC WITH `maud/src/escape.rs` !!!!!!!!!
3
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4
+
5
+ extern crate alloc;
6
+
7
+ use alloc:: string:: String ;
8
+
9
+ pub fn escape_to_string ( input : & str , output : & mut String ) {
10
+ for b in input. bytes ( ) {
11
+ match b {
12
+ b'&' => output. push_str ( "&" ) ,
13
+ b'<' => output. push_str ( "<" ) ,
14
+ b'>' => output. push_str ( ">" ) ,
15
+ b'"' => output. push_str ( """ ) ,
16
+ _ => unsafe { output. as_mut_vec ( ) . push ( b) } ,
17
+ }
18
+ }
19
+ }
20
+
21
+ #[ cfg( test) ]
22
+ mod test {
23
+ extern crate alloc;
24
+
25
+ use super :: escape_to_string;
26
+ use alloc:: string:: String ;
27
+
28
+ #[ test]
29
+ fn it_works ( ) {
30
+ let mut s = String :: new ( ) ;
31
+ escape_to_string ( "<script>launchMissiles()</script>" , & mut s) ;
32
+ assert_eq ! ( s, "<script>launchMissiles()</script>" ) ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments