From a795fe637846e0d9561d2f7cdd84cfafd58b23a7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 25 Jul 2014 12:15:33 -0400 Subject: [PATCH] Allow quotation marks around feature tag in hb_feature_from_string() With this, I believe we accept CSS feature strings completely. --- src/hb-shape.cc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/hb-shape.cc b/src/hb-shape.cc index 2ed6ce979..f5a4ef284 100644 --- a/src/hb-shape.cc +++ b/src/hb-shape.cc @@ -117,16 +117,34 @@ parse_feature_tag (const char **pp, const char *end, hb_feature_t *feature) { parse_space (pp, end); - const char *p = *pp; - char c; + char quote = 0; + + if (*pp < end && (**pp == '\'' || **pp == '"')) + { + quote = **pp; + (*pp)++; + } - while (*pp < end && (c = **pp, ISALNUM(c))) + const char *p = *pp; + while (*pp < end && ISALNUM(**pp)) (*pp)++; if (p == *pp || *pp - p > 4) return false; feature->tag = hb_tag_from_string (p, *pp - p); + + if (quote) + { + /* CSS expects exactly four bytes. And we only allow quotations for + * CSS compatibility. So, enforce the length. */ + if (*pp - p != 4) + return false; + if (*pp == end || **pp != quote) + return false; + (*pp)++; + } + return true; }