summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-12 23:59:22 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-07-09 04:34:21 (GMT)
commit3e38a0c246536d064d722bf8c4db40ebf2275f5f (patch)
tree67e2be138c4368c8a51334ac83a1747aeeca16ed
parent02f5504de388eb69ded0bc9e05361d8db82c2137 (diff)
downloadlibhubbub-3e38a0c246536d064d722bf8c4db40ebf2275f5f.tar.gz
libhubbub-3e38a0c246536d064d722bf8c4db40ebf2275f5f.tar.bz2
Adding the COMMENT_END_BANG state for test3.dat
-rw-r--r--src/tokeniser/tokeniser.c25
-rw-r--r--test/data/tokeniser2/INDEX2
2 files changed, 25 insertions, 2 deletions
diff --git a/src/tokeniser/tokeniser.c b/src/tokeniser/tokeniser.c
index d108490..71cf35e 100644
--- a/src/tokeniser/tokeniser.c
+++ b/src/tokeniser/tokeniser.c
@@ -78,6 +78,7 @@ typedef enum hubbub_tokeniser_state {
STATE_COMMENT,
STATE_COMMENT_END_DASH,
STATE_COMMENT_END,
+ STATE_COMMENT_END_BANG,
STATE_MATCH_DOCTYPE,
STATE_DOCTYPE,
STATE_BEFORE_DOCTYPE_NAME,
@@ -539,6 +540,7 @@ hubbub_error hubbub_tokeniser_run(hubbub_tokeniser *tokeniser)
case STATE_COMMENT_START:
case STATE_COMMENT_START_DASH:
case STATE_COMMENT:
+ case STATE_COMMENT_END_BANG:
case STATE_COMMENT_END_DASH:
case STATE_COMMENT_END:
cont = hubbub_tokeniser_handle_comment(tokeniser);
@@ -1894,7 +1896,8 @@ hubbub_error hubbub_tokeniser_handle_comment(hubbub_tokeniser *tokeniser)
if (c == '>' && (tokeniser->state == STATE_COMMENT_START_DASH ||
tokeniser->state == STATE_COMMENT_START ||
- tokeniser->state == STATE_COMMENT_END)) {
+ tokeniser->state == STATE_COMMENT_END ||
+ tokeniser->state == STATE_COMMENT_END_BANG)) {
tokeniser->context.pending += len;
/** \todo parse error if state != COMMENT_END */
@@ -1916,9 +1919,21 @@ hubbub_error hubbub_tokeniser_handle_comment(hubbub_tokeniser *tokeniser)
return hubbub_error_from_parserutils_error(
error);
}
+ } else if (tokeniser->state == STATE_COMMENT_END_BANG) {
+ error = parserutils_buffer_append(tokeniser->buffer,
+ (uint8_t *) "--!", SLEN("--!"));
+ if (error != PARSERUTILS_OK) {
+ return hubbub_error_from_parserutils_error(
+ error);
+ }
+ tokeniser->state = STATE_COMMENT_END_DASH;
}
tokeniser->context.pending += len;
+ } else if (c == '!' && tokeniser->state == STATE_COMMENT_END) {
+ tokeniser->state = STATE_COMMENT_END_BANG;
+ tokeniser->context.pending += len;
+ return HUBBUB_OK;
} else {
if (tokeniser->state == STATE_COMMENT_START_DASH ||
tokeniser->state == STATE_COMMENT_END_DASH) {
@@ -1935,8 +1950,16 @@ hubbub_error hubbub_tokeniser_handle_comment(hubbub_tokeniser *tokeniser)
return hubbub_error_from_parserutils_error(
error);
}
+ } else if (tokeniser->state == STATE_COMMENT_END_BANG) {
+ error = parserutils_buffer_append(tokeniser->buffer,
+ (uint8_t *) "--!", SLEN("--!"));
+ if (error != PARSERUTILS_OK) {
+ return hubbub_error_from_parserutils_error(
+ error);
+ }
}
+
if (c == '\0') {
error = parserutils_buffer_append(tokeniser->buffer,
u_fffd, sizeof(u_fffd));
diff --git a/test/data/tokeniser2/INDEX b/test/data/tokeniser2/INDEX
index 1f6ea93..96daa2a 100644
--- a/test/data/tokeniser2/INDEX
+++ b/test/data/tokeniser2/INDEX
@@ -4,7 +4,7 @@
test1.test html5lib tests (part 1)
test2.test html5lib tests (part 2)
-#test3.test html5lib tests (part 3)
+test3.test html5lib tests (part 3)
#test4.test html5lib tests (part 4)
#contentModelFlags.test html5lib content model tests
#entities.test html5lib entity tests