diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2012-02-05 23:04:24 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2012-02-05 23:04:24 +0000 |
commit | ebd543e0bc08a7df3c0c9a4bbb575f2dcafd270b (patch) | |
tree | f7e98db6dda9fc11dd0adfd30dcc6705ce13975c | |
parent | 967540245c4e577e8a26959a88ae7703f760cc61 (diff) | |
download | libdom-ebd543e0bc08a7df3c0c9a4bbb575f2dcafd270b.tar.gz libdom-ebd543e0bc08a7df3c0c9a4bbb575f2dcafd270b.tar.bz2 |
Intern attribute and element names
svn path=/trunk/libdom/; revision=13426
-rw-r--r-- | bindings/hubbub/parser.c | 30 |
1 files changed, 27 insertions, 3 deletions
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 <libwapcaplet/libwapcaplet.h> @@ -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) { |