]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Don't guess length of xml header, iterate forward to <repository>
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 19 Mar 2021 15:00:49 +0000 (16:00 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 4 Apr 2021 13:43:21 +0000 (15:43 +0200)
If e.g. the xml header is missing, it resulted in errors like:

    error: expected start element of `repository'
    error: unsupported GIR version (null) (supported: 1.2)

vala/valagirparser.vala

index 6c8a5f2d59240a60a80643d2502f04beca1f756f..ad0dbf69df4400e48b729d4d258cfd83787523c6 100644 (file)
@@ -1479,10 +1479,14 @@ public class Vala.GirParser : CodeVisitor {
                reader = new MarkupReader (source_file.filename);
 
                // xml prolog
-               next ();
-               next ();
+               do {
+                       next ();
+                       if (current_token == MarkupTokenType.EOF) {
+                               Report.error (get_current_src (), "unexpected end of file");
+                               return;
+                       }
+               } while (current_token != MarkupTokenType.START_ELEMENT && reader.name != "repository");
 
-               next ();
                parse_repository ();
 
                reader = null;