summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-07-28 13:59:33 +0530
committerRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-08-01 21:44:34 +0530
commiteb03e32c68b81e953b0c3d86b657505eff7a8469 (patch)
tree98e8476c91dd8b5921983b57cf0ee9775d64cd8c
parent32c36a8042713a3a25fe829f4839f06431d77295 (diff)
downloadlibhubbub-eb03e32c68b81e953b0c3d86b657505eff7a8469.tar.gz
libhubbub-eb03e32c68b81e953b0c3d86b657505eff7a8469.tar.bz2
correctly handle meta element in head
-rw-r--r--src/treebuilder/in_head.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/treebuilder/in_head.c b/src/treebuilder/in_head.c
index a10ba23..9429058 100644
--- a/src/treebuilder/in_head.c
+++ b/src/treebuilder/in_head.c
@@ -33,6 +33,7 @@ static hubbub_error process_meta_in_head(hubbub_treebuilder *treebuilder,
uint16_t content_type_enc = 0;
size_t i;
hubbub_error err = HUBBUB_OK;
+ bool http_equiv = false;
err = insert_element(treebuilder, &token->data.tag, false);
if (err != HUBBUB_OK)
@@ -57,6 +58,20 @@ static hubbub_error process_meta_in_head(hubbub_treebuilder *treebuilder,
for (i = 0; i < token->data.tag.n_attributes; i++) {
hubbub_attribute *attr = &token->data.tag.attributes[i];
+ if (hubbub_string_match_ci(attr->name.ptr, attr->name.len,
+ (const uint8_t *) "http-equiv",
+ SLEN("http-equiv")) == true &&
+ hubbub_string_match_ci(attr->value.ptr, attr->value.len,
+ (const uint8_t *) "content-type",
+ SLEN("content-type")) == true
+ ) {
+ http_equiv = true;
+ }
+ }
+
+ for (i = 0; i < token->data.tag.n_attributes; i++) {
+ hubbub_attribute *attr = &token->data.tag.attributes[i];
+
if (hubbub_string_match(attr->name.ptr, attr->name.len,
(const uint8_t *) "charset",
SLEN("charset")) == true) {
@@ -66,7 +81,8 @@ static hubbub_error process_meta_in_head(hubbub_treebuilder *treebuilder,
attr->value.len);
} else if (hubbub_string_match(attr->name.ptr, attr->name.len,
(const uint8_t *) "content",
- SLEN("content")) == true) {
+ SLEN("content")) == true &&
+ http_equiv == true) {
/* Extract charset from Content-Type */
content_type_enc = hubbub_charset_parse_content(
attr->value.ptr, attr->value.len);