diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-03-02 12:37:16 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-03-02 12:37:16 +0100 |
commit | bc05c00f84d0c709f179478c968c1bab26f62a23 (patch) | |
tree | 53608b30f20683deac71b8a4be4e07fbf50a8540 | |
parent | a365e60245170686a147c3871cc518aa05deb565 (diff) | |
download | totem-pl-parser-bc05c00f84d0c709f179478c968c1bab26f62a23.tar.gz |
core: Ignore trailing spaces in element names
Closes: #28
-rw-r--r-- | plparse/xmlparser.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plparse/xmlparser.c b/plparse/xmlparser.c index 3015960..a2da15c 100644 --- a/plparse/xmlparser.c +++ b/plparse/xmlparser.c @@ -273,6 +273,13 @@ static xml_node_t *xml_parser_append_text (xml_node_t *node, xml_node_t *subnode #define Q_STATE(CURRENT,NEW) (STATE_##NEW + state - STATE_##CURRENT) +static int is_space(const char *str) +{ + char *text = str; + while (isspace (*text)) + ++text; + return (*text == '\0'); +} static int xml_parser_get_node_internal (xml_parser_t *xml_parser, char ** token_buffer, int * token_buffer_size, @@ -530,8 +537,10 @@ static int xml_parser_get_node_internal (xml_parser_t *xml_parser, return retval; break; default: - lprintf("error: unexpected token \"%s\", state %s (%d)\n", tok, state_to_str(state), state); - return -1; + if (!is_space(tok)) { + lprintf("error: unexpected token \"%s\", state %s (%d)\n", tok, state_to_str(state), state); + return -1; + } break; } break; |