summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-07-17 13:17:04 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-08-01 16:14:34 (GMT)
commitcef912a36f581deefa3674d1bd988beb9473acbb (patch)
treecac06c86c0a63d8b5fb50cd4f013b1faf665b6d8
parentbef193cb94318d6fe1f7f005f43d751d69224651 (diff)
downloadlibhubbub-cef912a36f581deefa3674d1bd988beb9473acbb.tar.gz
libhubbub-cef912a36f581deefa3674d1bd988beb9473acbb.tar.bz2
Correctly handled NULL characters at some places
-rw-r--r--src/treebuilder/in_body.c4
-rw-r--r--src/treebuilder/in_foreign_content.c12
-rw-r--r--src/treebuilder/in_select.c3
3 files changed, 17 insertions, 2 deletions
diff --git a/src/treebuilder/in_body.c b/src/treebuilder/in_body.c
index dcccdd0..33b563e 100644
--- a/src/treebuilder/in_body.c
+++ b/src/treebuilder/in_body.c
@@ -204,6 +204,10 @@ hubbub_error process_character(hubbub_treebuilder *treebuilder,
bool lr_flag = treebuilder->context.strip_leading_lr;
const uint8_t *p;
+ if(dummy.ptr[0] == '\0') {
+ return HUBBUB_OK;
+ }
+
err = reconstruct_active_formatting_list(treebuilder);
if (err != HUBBUB_OK)
return err;
diff --git a/src/treebuilder/in_foreign_content.c b/src/treebuilder/in_foreign_content.c
index 97fb1d0..ddade53 100644
--- a/src/treebuilder/in_foreign_content.c
+++ b/src/treebuilder/in_foreign_content.c
@@ -20,6 +20,12 @@
#define S(s) s, SLEN(s)
/**
+ * UTF-8 encoding of U+FFFD REPLACEMENT CHARACTER
+ */
+static const uint8_t u_fffd[3] = { '\xEF', '\xBF', '\xBD' };
+static const hubbub_string u_fffd_str = { u_fffd, sizeof(u_fffd) };
+
+/**
* Mapping table for case changes
*/
typedef struct
@@ -436,9 +442,11 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
is_mathml_text_integration(cur_node, cur_node_ns)) {
return process_as_in_secondary(treebuilder, token);
}
-
c = (token->data.character.ptr);
- if(*c != '\t' && *c != '\r' && *c != ' ' && *c != '\n' && *c != '\f') {
+ if(c[0] == '\0') {
+ err = append_text(treebuilder, &u_fffd_str);
+ return err;
+ } else if(*c != '\t' && *c != '\r' && *c != ' ' && *c != '\n' && *c != '\f') {
treebuilder->context.frameset_ok = false;
}
diff --git a/src/treebuilder/in_select.c b/src/treebuilder/in_select.c
index 7c15b49..7675dc5 100644
--- a/src/treebuilder/in_select.c
+++ b/src/treebuilder/in_select.c
@@ -32,6 +32,9 @@ hubbub_error handle_in_select(hubbub_treebuilder *treebuilder,
switch (token->type) {
case HUBBUB_TOKEN_CHARACTER:
+ if((token->data.character.ptr[0]) == '\0') {
+ break;
+ }
err = append_text(treebuilder, &token->data.character);
break;
case HUBBUB_TOKEN_COMMENT: