File tree Expand file tree Collapse file tree 2 files changed +14
-19
lines changed Expand file tree Collapse file tree 2 files changed +14
-19
lines changed Original file line number Diff line number Diff line change @@ -17,22 +17,17 @@ impl<'a> fmt::Display for Escape<'a> {
1717 let pile_o_bits = s;
1818 let mut last = 0 ;
1919 for ( i, ch) in s. bytes ( ) . enumerate ( ) {
20- match ch as char {
21- '<' | '>' | '&' | '\'' | '"' => {
22- fmt. write_str ( & pile_o_bits[ last..i] ) ?;
23- let s = match ch as char {
24- '>' => ">" ,
25- '<' => "<" ,
26- '&' => "&" ,
27- '\'' => "'" ,
28- '"' => """ ,
29- _ => unreachable ! ( ) ,
30- } ;
31- fmt. write_str ( s) ?;
32- last = i + 1 ;
33- }
34- _ => { }
35- }
20+ let s = match ch as char {
21+ '>' => ">" ,
22+ '<' => "<" ,
23+ '&' => "&" ,
24+ '\'' => "'" ,
25+ '"' => """ ,
26+ _ => continue ,
27+ } ;
28+ fmt. write_str ( & pile_o_bits[ last..i] ) ?;
29+ fmt. write_str ( s) ?;
30+ last = i + 1 ;
3631 }
3732
3833 if last < s. len ( ) {
Original file line number Diff line number Diff line change @@ -4267,8 +4267,8 @@ fn get_methods(
42674267fn small_url_encode ( s : String ) -> String {
42684268 let mut st = String :: new ( ) ;
42694269 let mut last_match = 0 ;
4270- for ( idx, c) in s. char_indices ( ) {
4271- let escaped = match c {
4270+ for ( idx, c) in s. bytes ( ) . enumerate ( ) {
4271+ let escaped = match c as char {
42724272 '<' => "%3C" ,
42734273 '>' => "%3E" ,
42744274 ' ' => "%20" ,
@@ -4286,7 +4286,7 @@ fn small_url_encode(s: String) -> String {
42864286
42874287 st += & s[ last_match..idx] ;
42884288 st += escaped;
4289- last_match = idx + c . len_utf8 ( ) ;
4289+ last_match = idx + 1 ;
42904290 }
42914291
42924292 if last_match != 0 {
You can’t perform that action at this time.
0 commit comments