From 1249e7fb2869d117db4357586ecb50b601f2e083 Mon Sep 17 00:00:00 2001 From: Daniel Espinosa Date: Tue, 12 Jan 2016 10:16:31 -0600 Subject: [PATCH] Fixed xDocument.from_string() no root element --- configure.ac | 4 ++-- gxml/libxml-Document.vala | 2 ++ test/DocumentTest.vala | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ac3443a9..9c0fbb66 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ # Release Version m4_define([project_major_version], [0]) m4_define([project_minor_version], [8]) -m4_define([project_micro_version], [0]) +m4_define([project_micro_version], [1]) m4_define([project_nano_version], [0]) # LT_VERSION @@ -22,7 +22,7 @@ m4_define([project_nano_version], [0]) # If public symbols have been added since last release, increment age # If public symbols have been removed since last release, set age to 0 m4_define([project_lt_current], [8]) -m4_define([project_lt_revision], [0]) +m4_define([project_lt_revision], [1]) m4_define([project_lt_age], [0]) # Combine numbers to various version variables (different uses) diff --git a/gxml/libxml-Document.vala b/gxml/libxml-Document.vala index a160599f..dfe27902 100644 --- a/gxml/libxml-Document.vala +++ b/gxml/libxml-Document.vala @@ -475,6 +475,8 @@ namespace GXml { public xDocument.from_string (string xml) { Xml.Doc *doc; doc = Xml.Parser.parse_memory (xml, (int)xml.length); + if (doc == null) + doc = new Xml.Doc (); this.from_libxml2 (doc); } /** diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala index afb83913..4829fe1a 100644 --- a/test/DocumentTest.vala +++ b/test/DocumentTest.vala @@ -143,6 +143,17 @@ class DocumentTest : GXmlTest { assert (root.first_child.node_name == "Apple"); assert (root.last_child.node_name == "Orange"); }); + Test.add_func ("/gxml/document/construct_from_string_no_root", () => { + string xml; + xDocument doc; + GXml.xNode root; + + xml = """"""; + doc = new xDocument.from_string (xml); + + root = doc.document_element; + assert (root == null); + }); Test.add_func ("/gxml/document/save", () => { xDocument doc; int exit_status; -- GitLab