summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-06 16:15:49 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-06 16:15:49 +0100
commit0580bd8eed161949889506e792979de2458852db (patch)
treec9f5c339f3657237ebe2374aaaaa4d2bd7fed408
parent9199df40bc95d4d54a954d2d2d4d0ec74b0e5163 (diff)
downloadlibhubbub-0580bd8eed161949889506e792979de2458852db.tar.gz
libhubbub-0580bd8eed161949889506e792979de2458852db.tar.bz2
Consume insert_buf when resuming a parseHEADmaster
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r--src/tokeniser/tokeniser.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tokeniser/tokeniser.c b/src/tokeniser/tokeniser.c
index a7e67a1..2d9c4ed 100644
--- a/src/tokeniser/tokeniser.c
+++ b/src/tokeniser/tokeniser.c
@@ -393,6 +393,24 @@ hubbub_error hubbub_tokeniser_setopt(hubbub_tokeniser *tokeniser,
} else {
if (tokeniser->paused == true) {
tokeniser->paused = false;
+ /* When unpausing, if we have had something
+ * akin to document.write() happen while
+ * we were paused, then the insert_buf will
+ * have some content.
+ * In this case, we need to prepend it to
+ * the input buffer before we resume parsing,
+ * discarding the insert_buf as we go.
+ */
+ if (tokeniser->insert_buf->length > 0) {
+ parserutils_inputstream_insert(
+ tokeniser->input,
+ tokeniser->insert_buf->data,
+ tokeniser->insert_buf->length);
+ parserutils_buffer_discard(
+ tokeniser->insert_buf, 0,
+ tokeniser->insert_buf->length);
+ }
+
err = hubbub_tokeniser_run(tokeniser);
}
}