1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

Add support for scanning comment endings such as '--!>' correctly

This commit is contained in:
Jonas Fonseca 2006-01-25 18:18:01 +01:00 committed by Jonas Fonseca
parent cda61d0176
commit afb45aace5
2 changed files with 22 additions and 7 deletions

View File

@ -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
* are supposed to have '<!--' before this is called. We do
* however need to check that the '-->' are not overlapping any
* preceeding '-'. */
if (pos[-2] == '-' && pos[-1] == '-' && &pos[-2] >= *string) {
length = pos - *string - 2;
*possibly_incomplete = 0;
pos++;
break;
* preceeding '-'. Additionally also handle the quirky '--!>'
* end sometimes found. */
if (pos[-2] == '-') {
if (pos[-1] == '-' && &pos[-2] >= *string) {
length = pos - *string - 2;
*possibly_incomplete = 0;
pos++;
break;
} else if (pos[-1] == '!' && pos[-3] == '-' && &pos[-3] >= *string) {
length = pos - *string - 3;
*possibly_incomplete = 0;
pos++;
break;
}
}
}

View File

@ -93,11 +93,18 @@ test_output_equals \
#text: u'
test_output_equals \
'Parse bad comment.' \
'Parse bad comment. (I)' \
'<!--->s' \
'
#comment: ->s'
test_output_equals \
'Parse bad comment. (II)' \
'<!--a--!>bad comment' \
'
#comment: a
#text: bad comment'
test_output_equals \
'Parse empty notation.' \
'<!>s' \