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> {
17
17
let pile_o_bits = s;
18
18
let mut last = 0 ;
19
19
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 ;
36
31
}
37
32
38
33
if last < s. len ( ) {
Original file line number Diff line number Diff line change @@ -4267,8 +4267,8 @@ fn get_methods(
4267
4267
fn small_url_encode ( s : String ) -> String {
4268
4268
let mut st = String :: new ( ) ;
4269
4269
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 {
4272
4272
'<' => "%3C" ,
4273
4273
'>' => "%3E" ,
4274
4274
' ' => "%20" ,
@@ -4286,7 +4286,7 @@ fn small_url_encode(s: String) -> String {
4286
4286
4287
4287
st += & s[ last_match..idx] ;
4288
4288
st += escaped;
4289
- last_match = idx + c . len_utf8 ( ) ;
4289
+ last_match = idx + 1 ;
4290
4290
}
4291
4291
4292
4292
if last_match != 0 {
You can’t perform that action at this time.
0 commit comments