@@ -9,35 +9,36 @@ def Yadis.html_yadis_location(html)
9
9
# to keep track of whether or not we are in the head element
10
10
in_head = false
11
11
12
- while el = parser . getTag ( 'head' , '/head' , 'meta' , 'body' , '/body' , 'html' ,
13
- 'script' )
12
+ begin
13
+ while el = parser . getTag ( 'head' , '/head' , 'meta' , 'body' , '/body' ,
14
+ 'html' , 'script' )
14
15
15
- # we are leaving head or have reached body, so we bail
16
- return nil if [ '/head' , 'body' , '/body' ] . member? ( el . tag_name )
16
+ # we are leaving head or have reached body, so we bail
17
+ return nil if [ '/head' , 'body' , '/body' ] . member? ( el . tag_name )
17
18
18
- if el . tag_name == 'head'
19
- unless el . to_s [ -2 ] == ?/ # tag ends with a /: a short tag
20
- in_head = true
19
+ if el . tag_name == 'head'
20
+ unless el . to_s [ -2 ] == ?/ # tag ends with a /: a short tag
21
+ in_head = true
22
+ end
21
23
end
22
- end
23
- next unless in_head
24
+ next unless in_head
24
25
25
- if el . tag_name == 'script'
26
- unless el . to_s [ -2 ] == ?/ # tag ends with a /: a short tag
27
- parser . getTag ( '/script' )
26
+ if el . tag_name == 'script'
27
+ unless el . to_s [ -2 ] == ?/ # tag ends with a /: a short tag
28
+ parser . getTag ( '/script' )
29
+ end
28
30
end
29
- end
30
31
31
- return nil if el . tag_name == 'html'
32
+ return nil if el . tag_name == 'html'
32
33
33
- if el . tag_name == 'meta' and ( equiv = el . attr_hash [ 'http-equiv' ] )
34
- if [ 'x-xrds-location' , 'x-yadis-location' ] . member? ( equiv . downcase )
35
- return CGI ::unescapeHTML ( el . attr_hash [ 'content' ] )
34
+ if el . tag_name == 'meta' and ( equiv = el . attr_hash [ 'http-equiv' ] )
35
+ if [ 'x-xrds-location' , 'x-yadis-location' ] . member? ( equiv . downcase )
36
+ return CGI ::unescapeHTML ( el . attr_hash [ 'content' ] )
37
+ end
36
38
end
37
39
end
38
-
40
+ rescue HTMLTokenizerError # just stop parsing if there's an error
39
41
end
40
42
end
41
43
end
42
44
end
43
-
0 commit comments