File tree Expand file tree Collapse file tree 6 files changed +23
-12
lines changed Expand file tree Collapse file tree 6 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -2167,6 +2167,7 @@ version = "0.1.0"
2167
2167
dependencies = [
2168
2168
" html5ever" ,
2169
2169
" regex" ,
2170
+ " urlencoding" ,
2170
2171
]
2171
2172
2172
2173
[[package ]]
@@ -5825,6 +5826,12 @@ dependencies = [
5825
5826
" percent-encoding" ,
5826
5827
]
5827
5828
5829
+ [[package ]]
5830
+ name = " urlencoding"
5831
+ version = " 2.1.3"
5832
+ source = " registry+https://github.com/rust-lang/crates.io-index"
5833
+ checksum = " daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
5834
+
5828
5835
[[package ]]
5829
5836
name = " utf-8"
5830
5837
version = " 0.7.6"
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