mirror of
https://github.com/rkd77/elinks.git
synced 2025-04-18 00:47:36 -04:00
Add support for scanning comment endings such as '--!>' correctly
This commit is contained in:
parent
cda61d0176
commit
afb45aace5
@ -368,12 +368,20 @@ skip_sgml_comment(struct dom_scanner *scanner, unsigned char **string,
|
|||||||
/* It is always safe to access index -2 and -1 here since we
|
/* It is always safe to access index -2 and -1 here since we
|
||||||
* are supposed to have '<!--' before this is called. We do
|
* are supposed to have '<!--' before this is called. We do
|
||||||
* however need to check that the '-->' are not overlapping any
|
* however need to check that the '-->' are not overlapping any
|
||||||
* preceeding '-'. */
|
* preceeding '-'. Additionally also handle the quirky '--!>'
|
||||||
if (pos[-2] == '-' && pos[-1] == '-' && &pos[-2] >= *string) {
|
* end sometimes found. */
|
||||||
length = pos - *string - 2;
|
if (pos[-2] == '-') {
|
||||||
*possibly_incomplete = 0;
|
if (pos[-1] == '-' && &pos[-2] >= *string) {
|
||||||
pos++;
|
length = pos - *string - 2;
|
||||||
break;
|
*possibly_incomplete = 0;
|
||||||
|
pos++;
|
||||||
|
break;
|
||||||
|
} else if (pos[-1] == '!' && pos[-3] == '-' && &pos[-3] >= *string) {
|
||||||
|
length = pos - *string - 3;
|
||||||
|
*possibly_incomplete = 0;
|
||||||
|
pos++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,11 +93,18 @@ test_output_equals \
|
|||||||
#text: u'
|
#text: u'
|
||||||
|
|
||||||
test_output_equals \
|
test_output_equals \
|
||||||
'Parse bad comment.' \
|
'Parse bad comment. (I)' \
|
||||||
'<!--->s' \
|
'<!--->s' \
|
||||||
'
|
'
|
||||||
#comment: ->s'
|
#comment: ->s'
|
||||||
|
|
||||||
|
test_output_equals \
|
||||||
|
'Parse bad comment. (II)' \
|
||||||
|
'<!--a--!>bad comment' \
|
||||||
|
'
|
||||||
|
#comment: a
|
||||||
|
#text: bad comment'
|
||||||
|
|
||||||
test_output_equals \
|
test_output_equals \
|
||||||
'Parse empty notation.' \
|
'Parse empty notation.' \
|
||||||
'<!>s' \
|
'<!>s' \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user