summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/treebuilder/in_table.c8
-rw-r--r--src/treebuilder/initial.c37
-rw-r--r--src/treebuilder/treebuilder.c22
3 files changed, 23 insertions, 44 deletions
diff --git a/src/treebuilder/in_table.c b/src/treebuilder/in_table.c
index 3cc487f..c5bb22e 100644
--- a/src/treebuilder/in_table.c
+++ b/src/treebuilder/in_table.c
@@ -49,9 +49,9 @@ static inline bool process_input_in_table(hubbub_treebuilder *treebuilder,
for (size_t i = 0; i < token->data.tag.n_attributes; i++) {
hubbub_attribute *attr = &token->data.tag.attributes[i];
- if (!hubbub_string_match(treebuilder->input_buffer +
- attr->name.data.off,
- attr->name.len, (uint8_t *) "hidden",
+ if (!hubbub_string_match_ci(treebuilder->input_buffer +
+ attr->value.data.off,
+ attr->value.len, (uint8_t *) "hidden",
SLEN("hidden"))) {
continue;
}
@@ -129,7 +129,7 @@ bool handle_in_table(hubbub_treebuilder *treebuilder,
if (type == COL) {
/* Insert colgroup and reprocess */
tag.name.type = HUBBUB_STRING_PTR;
- tag.name.data.ptr =
+ tag.name.data.ptr =
(const uint8_t *) "colgroup";
tag.name.len = SLEN("colgroup");
diff --git a/src/treebuilder/initial.c b/src/treebuilder/initial.c
index a1e623d..70869b9 100644
--- a/src/treebuilder/initial.c
+++ b/src/treebuilder/initial.c
@@ -14,6 +14,7 @@
#include "treebuilder/internal.h"
#include "treebuilder/treebuilder.h"
#include "utils/utils.h"
+#include "utils/string.h"
#define S(s) { s, sizeof s }
@@ -107,32 +108,6 @@ static bool starts_with(const uint8_t *a, size_t a_len, const uint8_t *b,
return true;
}
-/**
- * Check that one string is exactly equal to another
- *
- * \param a String to compare
- * \param a_len Length of first string
- * \param b String to compare
- * \param b_len Length of second string
- */
-static bool match(const uint8_t *a, size_t a_len, const uint8_t *b,
- size_t b_len)
-{
- uint8_t z1, z2;
-
- if (a_len != b_len)
- return false;
-
- for (const uint8_t *s1 = a, *s2 = b; b_len > 0; s1++, s2++, b_len--)
- {
- z1 = (*s1 & ~0x20);
- z2 = (*s2 & ~0x20);
- if (z1 != z2) return false;
- }
-
- return true;
-}
-
/**
* Determine whether this doctype triggers full quirks mode
@@ -159,7 +134,7 @@ static bool lookup_full_quirks(hubbub_treebuilder *treebuilder,
#define S(s) (uint8_t *) s, sizeof s
/* Check the name is "HTML" (case-insensitively) */
- if (!match(name, name_len, S("HTML")))
+ if (!hubbub_string_match_ci(name, name_len, S("HTML")))
return true;
/* No public id means not-quirks */
@@ -174,13 +149,13 @@ static bool lookup_full_quirks(hubbub_treebuilder *treebuilder,
}
}
- if (match(public_id, public_id_len,
+ if (hubbub_string_match_ci(public_id, public_id_len,
S("-//W3O//DTD W3 HTML Strict 3.0//EN//")) ||
- match(public_id, public_id_len,
+ hubbub_string_match_ci(public_id, public_id_len,
S("-/W3C/DTD HTML 4.0 Transitional/EN")) ||
- match(public_id, public_id_len,
+ hubbub_string_match_ci(public_id, public_id_len,
S("HTML")) ||
- match(system_id, system_id_len,
+ hubbub_string_match_ci(system_id, system_id_len,
S("http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"))) {
return true;
}
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index c9a41be..1f6baef 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -517,16 +517,20 @@ void parse_generic_rcdata(hubbub_treebuilder *treebuilder,
/** \todo associate textarea with form */
}
- success = treebuilder->tree_handler->append_child(
- treebuilder->tree_handler->ctx,
- treebuilder->context.element_stack[
- treebuilder->context.current_node].node,
- node, &appended);
- if (success != 0) {
- /** \todo errors */
- treebuilder->tree_handler->unref_node(
+ if (treebuilder->context.in_table_foster) {
+ aa_insert_into_foster_parent(treebuilder, node);
+ } else {
+ success = treebuilder->tree_handler->append_child(
treebuilder->tree_handler->ctx,
- node);
+ treebuilder->context.element_stack[
+ treebuilder->context.current_node].node,
+ node, &appended);
+ if (success != 0) {
+ /** \todo errors */
+ treebuilder->tree_handler->unref_node(
+ treebuilder->tree_handler->ctx,
+ node);
+ }
}
params.content_model.model = rcdata ? HUBBUB_CONTENT_MODEL_RCDATA