summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/charset/detect.c19
2 files changed, 18 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ded29b8..609a481 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# Component settings
COMPONENT := hubbub
-COMPONENT_VERSION := 0.3.3
+COMPONENT_VERSION := 0.3.4
# 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)) {