File tree Expand file tree Collapse file tree 5 files changed +16
-12
lines changed Expand file tree Collapse file tree 5 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ path = "main.rs"
10
10
[dependencies ]
11
11
regex = " 1"
12
12
html5ever = " 0.29.0"
13
+ urlencoding = " 2.1.3"
Original file line number Diff line number Diff line change @@ -232,18 +232,7 @@ enum FileEntry {
232
232
type Cache = HashMap < String , FileEntry > ;
233
233
234
234
fn small_url_encode ( s : & str ) -> String {
235
- s. replace ( '<' , "%3C" )
236
- . replace ( '>' , "%3E" )
237
- . replace ( ' ' , "%20" )
238
- . replace ( '?' , "%3F" )
239
- . replace ( '\'' , "%27" )
240
- . replace ( '&' , "%26" )
241
- . replace ( ',' , "%2C" )
242
- . replace ( ':' , "%3A" )
243
- . replace ( ';' , "%3B" )
244
- . replace ( '[' , "%5B" )
245
- . replace ( ']' , "%5D" )
246
- . replace ( '\"' , "%22" )
235
+ urlencoding:: encode ( s) . to_string ( )
247
236
}
248
237
249
238
impl Checker {
Original file line number Diff line number Diff line change 3
3
4
4
< h2 id ="barfrag "> Bar</ h2 >
5
5
6
+ <!-- testing urlecoded anchor link against a non-urlencoded heading IDs -->
7
+ < h2 id ="barfrag-è "> Bar</ h2 >
8
+
6
9
</ body >
7
10
</ html >
Original file line number Diff line number Diff line change 8
8
< a href ="https://example.com/doesnotexist "> external links not validated</ a >
9
9
< a href ="redir.html#redirfrag "> Redirect</ a >
10
10
11
+ <!-- testing urlecoded anchor link against a non-urlencoded heading IDs -->
12
+ < a href ="#localfrag-%C3%A8 "> </ a >
13
+ < a href ="bar.html#barfrag-%C3%A8 "> </ a >
14
+ < a href ="redir.html#redirfrag-%C3%A8 "> </ a >
15
+
11
16
< h2 id ="localfrag "> Local</ h2 >
12
17
18
+ <!-- testing urlecoded anchor link against a non-urlencoded heading IDs -->
19
+ < h2 id ="localfrag-è "> Local</ h2 >
20
+
13
21
</ body >
14
22
</ html >
Original file line number Diff line number Diff line change 1
1
< html >
2
2
< body >
3
3
< h2 id ="redirfrag "> Redir</ h2 >
4
+
5
+ <!-- testing urlecoded anchor link against a non-urlencoded heading IDs -->
6
+ < h2 id ="redirfrag-è "> Redir</ h2 >
4
7
</ body >
5
8
</ html >
You can’t perform that action at this time.
0 commit comments