[Libguestfs] [PATCH] builder: ignore spaces after repo identifiers (RHBZ#1506511)

Pino Toscano ptoscano at redhat.com
Thu Oct 26 14:11:56 UTC 2017


---
 builder/index-scan.l                    | 5 +++--
 builder/test-virt-index-validate-good-4 | 3 +++
 builder/test-virt-index-validate.sh     | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 builder/test-virt-index-validate-good-4

diff --git a/builder/index-scan.l b/builder/index-scan.l
index bdb474b33..49dad72bc 100644
--- a/builder/index-scan.l
+++ b/builder/index-scan.l
@@ -78,8 +78,9 @@ extern void scanner_destroy (yyscan_t scanner);
 ^\n                                     { return EMPTY_LINE; }
 
   /* [...] marks beginning of a section. */
-^"["[-A-Za-z0-9._]+"]"\n {
-                      yylval->str = strndup (yytext+1, yyleng-3);
+^"["[-A-Za-z0-9._]+"]"[[:blank:]]*\n {
+                      const char *end = strrchr (yytext, ']');
+                      yylval->str = strndup (yytext+1, end-yytext-1);
                       return SECTION_HEADER;
                     }
 
diff --git a/builder/test-virt-index-validate-good-4 b/builder/test-virt-index-validate-good-4
new file mode 100644
index 000000000..8e8d1065b
--- /dev/null
+++ b/builder/test-virt-index-validate-good-4
@@ -0,0 +1,3 @@
+# Empty spaces after the repository identifier
+[foo] 	  
+key=value
diff --git a/builder/test-virt-index-validate.sh b/builder/test-virt-index-validate.sh
index b00a086b0..851285a1e 100755
--- a/builder/test-virt-index-validate.sh
+++ b/builder/test-virt-index-validate.sh
@@ -23,3 +23,4 @@ set -e
 $VG virt-index-validate test-virt-index-validate-good-1
 $VG virt-index-validate test-virt-index-validate-good-2
 $VG virt-index-validate test-virt-index-validate-good-3
+$VG virt-index-validate test-virt-index-validate-good-4
-- 
2.13.6




More information about the Libguestfs mailing list