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"
21672167dependencies = [
21682168 " html5ever" ,
21692169 " regex" ,
2170+ " urlencoding" ,
21702171]
21712172
21722173[[package ]]
@@ -5825,6 +5826,12 @@ dependencies = [
58255826 " percent-encoding" ,
58265827]
58275828
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+
58285835[[package ]]
58295836name = " utf-8"
58305837version = " 0.7.6"
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ path = "main.rs"
1010[dependencies ]
1111regex = " 1"
1212html5ever = " 0.29.0"
13+ urlencoding = " 2.1.3"
Original file line number Diff line number Diff line change @@ -232,18 +232,7 @@ enum FileEntry {
232232type Cache = HashMap < String , FileEntry > ;
233233
234234fn 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 ( )
247236}
248237
249238impl Checker {
Original file line number Diff line number Diff line change 33
44 < h2 id ="barfrag "> Bar</ h2 >
55
6+ <!-- testing urlecoded anchor link against a non-urlencoded heading IDs -->
7+ < h2 id ="barfrag-è "> Bar</ h2 >
8+
69</ body >
710</ html >
Original file line number Diff line number Diff line change 88 < a href ="https://example.com/doesnotexist "> external links not validated</ a >
99 < a href ="redir.html#redirfrag "> Redirect</ a >
1010
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+
1116 < h2 id ="localfrag "> Local</ h2 >
1217
18+ <!-- testing urlecoded anchor link against a non-urlencoded heading IDs -->
19+ < h2 id ="localfrag-è "> Local</ h2 >
20+
1321</ body >
1422</ html >
Original file line number Diff line number Diff line change 11< html >
22< body >
33 < h2 id ="redirfrag "> Redir</ h2 >
4+
5+ <!-- testing urlecoded anchor link against a non-urlencoded heading IDs -->
6+ < h2 id ="redirfrag-è "> Redir</ h2 >
47</ body >
58</ html >
You can’t perform that action at this time.
0 commit comments