summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/charset/detect.c19
-rw-r--r--test/tokeniser3.c2
-rw-r--r--test/tree-buf.c1
-rw-r--r--test/tree2.c24
5 files changed, 40 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index ded29b8..e4eec54 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# Component settings
COMPONENT := hubbub
-COMPONENT_VERSION := 0.3.3
+COMPONENT_VERSION := 0.3.5
# Default to a static library
COMPONENT_TYPE ?= lib-static
diff --git a/src/charset/detect.c b/src/charset/detect.c
index 93cbe63..d2d6816 100644
--- a/src/charset/detect.c
+++ b/src/charset/detect.c
@@ -369,6 +369,7 @@ uint16_t hubbub_charset_parse_attributes(const uint8_t **pos,
uint16_t hubbub_charset_parse_content(const uint8_t *value,
uint32_t valuelen)
{
+ const uint8_t *restart = value;
const uint8_t *end;
const uint8_t *tentative = NULL;
uint32_t tentative_len = 0;
@@ -388,8 +389,22 @@ uint16_t hubbub_charset_parse_content(const uint8_t *value,
value++;
}
- if (value >= end)
- return 0;
+ if (value >= end) {
+ /* Fallback, no semicolon, try for first whitespace */
+ value = restart;
+ while (value < end) {
+ /* This condition is odd, because ISSPACE() includes
+ * forward slash, which we need to skip so that content
+ * types work properly.
+ */
+ if (ISSPACE(*value) && (*value != '/')) {
+ value++;
+ break;
+ }
+
+ value++;
+ }
+ }
/* 2 */
while (value < end && ISSPACE(*value)) {
diff --git a/test/tokeniser3.c b/test/tokeniser3.c
index 949ddd0..e33d018 100644
--- a/test/tokeniser3.c
+++ b/test/tokeniser3.c
@@ -98,6 +98,8 @@ int main(int argc, char **argv)
run_test(&ctx);
}
+ json_object_put(json);
+
printf("PASS\n");
return 0;
diff --git a/test/tree-buf.c b/test/tree-buf.c
index 83447a2..94ee306 100644
--- a/test/tree-buf.c
+++ b/test/tree-buf.c
@@ -247,6 +247,7 @@ int main(int argc, char **argv)
printf("PASS\n");
+ free(chunks);
fclose(fp);
free(got.buf);
diff --git a/test/tree2.c b/test/tree2.c
index d5d4c72..6d8fb52 100644
--- a/test/tree2.c
+++ b/test/tree2.c
@@ -228,7 +228,10 @@ int main(int argc, char **argv)
buf_clear(&got);
buf_clear(&expected);
- hubbub_parser_destroy(parser);
+ if (parser != NULL) {
+ hubbub_parser_destroy(parser);
+ parser = NULL;
+ }
while (Document) {
node_t *victim = Document;
Document = victim->next;
@@ -237,6 +240,7 @@ int main(int argc, char **argv)
Document = NULL;
state = EXPECT_DATA;
+ /* Fall through. */
case EXPECT_DATA:
if (strcmp(line, "#data\n") == 0) {
@@ -315,7 +319,10 @@ int main(int argc, char **argv)
printf("%s", got.buf);
}
- hubbub_parser_destroy(parser);
+ if (parser != NULL) {
+ hubbub_parser_destroy(parser);
+ parser = NULL;
+ }
while (Document) {
node_t *victim = Document;
Document = victim->next;
@@ -330,6 +337,10 @@ int main(int argc, char **argv)
free(got.buf);
free(expected.buf);
+ if (parser != NULL) {
+ hubbub_parser_destroy(parser);
+ }
+
return 0;
}
@@ -878,9 +889,12 @@ static void node_print(buf_t *buf, node_t *node, unsigned depth)
buf_add(buf, node->data.element.name);
buf_add(buf, ">\n");
- qsort(node->data.element.attrs, node->data.element.n_attrs,
- sizeof *node->data.element.attrs,
- compare_attrs);
+ if (node->data.element.n_attrs > 0) {
+ qsort(node->data.element.attrs,
+ node->data.element.n_attrs,
+ sizeof *node->data.element.attrs,
+ compare_attrs);
+ }
for (i = 0; i < node->data.element.n_attrs; i++) {
indent(buf, depth + 1);