From 4044a2de24d1392f8578aa945bdaffaad12ca05e Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 5 Feb 2012 23:04:24 +0000 Subject: Intern attribute and element names svn path=/trunk/libdom/; revision=13426 --- bindings/hubbub/parser.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'bindings/hubbub/parser.c') diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c index 7e64cba..c030e77 100644 --- a/bindings/hubbub/parser.c +++ b/bindings/hubbub/parser.c @@ -19,6 +19,7 @@ #include "utils.h" #include "core/document.h" +#include "core/string.h" #include @@ -393,19 +394,30 @@ static hubbub_error create_element(void *parser, const hubbub_tag *tag, { dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser; dom_exception err; + lwc_string *iname; dom_string *name; struct dom_element *element = NULL; hubbub_error herr; *result = NULL; - err = dom_string_create(tag->name.ptr, tag->name.len, &name); + if (lwc_intern_string((const char *) tag->name.ptr, + tag->name.len, &iname) != lwc_error_ok) { + dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx, + "Can't create element name"); + goto fail; + } + + err = _dom_string_create_from_lwcstring(iname, &name); if (err != DOM_NO_ERR) { + lwc_string_unref(iname); dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx, "Can't create element name"); goto fail; } + lwc_string_unref(iname); + if (tag->ns == HUBBUB_NS_NULL) { err = dom_document_create_element(dom_parser->doc, name, &element); @@ -695,15 +707,27 @@ static hubbub_error add_attributes(void *parser, void *node, uint32_t i; for (i = 0; i < n_attributes; i++) { + lwc_string *iname; dom_string *name, *value; - err = dom_string_create(attributes[i].name.ptr, - attributes[i].name.len, &name); + + if (lwc_intern_string((const char *) attributes[i].name.ptr, + attributes[i].name.len, &iname) != + lwc_error_ok) { + dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx, + "Can't create attribute name"); + goto fail; + } + + err = _dom_string_create_from_lwcstring(iname, &name); if (err != DOM_NO_ERR) { + lwc_string_unref(iname); dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx, "Can't create attribute name"); goto fail; } + lwc_string_unref(iname); + err = dom_string_create(attributes[i].value.ptr, attributes[i].value.len, &value); if (err != DOM_NO_ERR) { -- cgit v1.2.3