File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -414,9 +414,15 @@ pub fn html_to_text(html: &str) -> String {
414414/// Extract attribute value from tag
415415fn extract_attribute ( tag : & str , attr : & str ) -> Option < String > {
416416 let pattern = format ! ( "{}=" , attr) ;
417- let tag_lower = tag. to_lowercase ( ) ;
418-
419- if let Some ( start) = tag_lower. find ( & pattern) {
417+ let start = tag
418+ . char_indices ( )
419+ . find_map ( |( idx, _) | {
420+ tag. get ( idx..idx + pattern. len ( ) )
421+ . filter ( |candidate| candidate. eq_ignore_ascii_case ( & pattern) )
422+ . map ( |_| idx)
423+ } ) ;
424+
425+ if let Some ( start) = start {
420426 let rest = & tag[ start + pattern. len ( ) ..] ;
421427 let rest = rest. trim_start ( ) ;
422428
@@ -1254,6 +1260,10 @@ mod tests {
12541260 extract_attribute( "div class=test" , "class" ) ,
12551261 Some ( "test" . to_string( ) )
12561262 ) ;
1263+ assert_eq ! (
1264+ extract_attribute( "a title=\" İİ\" href=x" , "href" ) ,
1265+ Some ( "x" . to_string( ) )
1266+ ) ;
12571267 }
12581268
12591269 #[ test]
You can’t perform that action at this time.
0 commit comments