Allow quotation marks around feature tag in hb_feature_from_string()

With this, I believe we accept CSS feature strings completely.
This commit is contained in:
Behdad Esfahbod 2014-07-25 12:15:33 -04:00
parent 3f64618474
commit a795fe6378
1 changed files with 21 additions and 3 deletions

View File

@ -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;
while (*pp < end && (c = **pp, ISALNUM(c)))
if (*pp < end && (**pp == '\'' || **pp == '"'))
{
quote = **pp;
(*pp)++;
}
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;
}