diff options
author | Yorhel <git@yorhel.nl> | 2013-09-04 16:59:30 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2013-09-04 16:59:30 +0200 |
commit | 49f4741c72498c28806d0064d09850536cb83969 (patch) | |
tree | 7942cb7c0b95e3754e1c99334b563f4877c43af5 | |
parent | 32eea7065c9a4e8af8d318620b338569b96bcb5f (diff) |
Normalize white space in attribute value data
-rw-r--r-- | yxml-states | 2 | ||||
-rw-r--r-- | yxml.c | 8 | ||||
-rw-r--r-- | yxml.c.in | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/yxml-states b/yxml-states index eeede4a..0c3bc27 100644 --- a/yxml-states +++ b/yxml-states @@ -149,6 +149,6 @@ elem3 '>' selfclose misc2 attr0 Name attrname attr0; SP attrnameend attr1; '=' attrnameend attr2 attr1 SP attr1; '=' attr2 attr2 SP attr2; '\''|'"' $quote attr3 -attr3 AttValue setdata attr3; '&' refstart attr4; $quote elem2 +attr3 AttValue setattrval attr3; '&' refstart attr4; $quote elem2 attr4 Ref ref attr4; '\x3b' refend attr3 @@ -116,6 +116,12 @@ static inline int yxml_setdata(yxml_t *x, unsigned ch) { } +static inline int yxml_setattrval(yxml_t *x, unsigned ch) { + /* Normalize attribute values according to the XML spec section 3.3.3. */ + return yxml_setdata(x, ch == 0x9 || ch == 0xa ? 0x20 : ch); +} + + /* Go to the misc1 or misc2 state, depending on whether a tag has been opened * previously or not. (This is a hack to work around a limitation in the state * machine description in yxml-states) */ @@ -339,7 +345,7 @@ yxml_ret_t yxml_parse(yxml_t *x, int _ch) { break; case YXMLS_attr3: if(yxml_isAttValue(ch)) - return yxml_setdata(x, ch); + return yxml_setattrval(x, ch); if(ch == (unsigned char)'&') { x->state = YXMLS_attr4; return yxml_refstart(x, ch); @@ -59,6 +59,12 @@ static inline int yxml_setdata(yxml_t *x, unsigned ch) { } +static inline int yxml_setattrval(yxml_t *x, unsigned ch) { + /* Normalize attribute values according to the XML spec section 3.3.3. */ + return yxml_setdata(x, ch == 0x9 || ch == 0xa ? 0x20 : ch); +} + + /* Go to the misc1 or misc2 state, depending on whether a tag has been opened * previously or not. (This is a hack to work around a limitation in the state * machine description in yxml-states) */ |