[msitools] wixl: return an error if XML parsing failed



commit ca7dc89cd0e820a8e349a8f3c64427916764776e
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Tue Nov 17 15:08:08 2020 +0400

    wixl: return an error if XML parsing failed
    
    Fixes:
    https://bugzilla.gnome.org/show_bug.cgi?id=792245
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 tests/wixl.bats              | 8 ++++++++
 tools/wixl/preprocessor.vala | 7 +++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/tests/wixl.bats b/tests/wixl.bats
index 50cc4ef..7e9a0b0 100644
--- a/tests/wixl.bats
+++ b/tests/wixl.bats
@@ -163,3 +163,11 @@ EOF
   out=$(cat list | "$wixlheat" -p test/ -x c | grep File | sort)
   [ "$out" = '          <File Id="fil18D0F9984B0565992BE4B64E573B4237" KeyPath="yes" 
Source="SourceDir/a/file"/>' ]
 }
+
+@test "wixl - XML error" {
+  cd wixl
+
+  echo " " > test.wxs
+  run "$wixl" test.wxs
+  [ "$status" -eq 1 ]
+}
diff --git a/tools/wixl/preprocessor.vala b/tools/wixl/preprocessor.vala
index b65d4f4..81e90c4 100644
--- a/tools/wixl/preprocessor.vala
+++ b/tools/wixl/preprocessor.vala
@@ -373,8 +373,9 @@ namespace Wixl {
         void preprocess_xml (Xml.TextReader reader, Xml.TextWriter writer, File? file, bool is_include = 
false) throws GLib.Error {
             IfContext context = new IfContext (true, true);
             var ifstack = new Queue<IfContext> ();
+            int status;
 
-            while (reader.read () > 0) {
+            while ((status = reader.read ()) > 0) {
                 var loc = new Location (reader, file);
                 bool handled = false;
 
@@ -489,6 +490,8 @@ namespace Wixl {
 
             if (!ifstack.is_empty ())
                 throw new Wixl.Error.FAILED ("Missing endif");
+            if (status != 0)
+                throw new Wixl.Error.FAILED ("Failed to parse XML");
         }
 
         bool include_try (string filename, Xml.TextWriter writer) throws GLib.Error {
@@ -546,4 +549,4 @@ namespace Wixl {
             return doc;
         }
     }
-}
\ No newline at end of file
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]