Pino Toscano
2015-Mar-13 14:02 UTC
[Libguestfs] [PATCH] builder: handle empty lines in indexes before first section (RHBZ#1201526)
Properly skip empty lines before the first section, otherwise they will trigger a syntax error in parsing. Add a simple test for it, so it doesn't regress. --- builder/index-parse.y | 8 ++++---- builder/test-virt-index-validate-good-3 | 4 ++++ builder/test-virt-index-validate.sh | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 builder/test-virt-index-validate-good-3 diff --git a/builder/index-parse.y b/builder/index-parse.y index 8ea2d73..82ea9d2 100644 --- a/builder/index-parse.y +++ b/builder/index-parse.y @@ -104,10 +104,10 @@ index: { context->parsed_index = $2; } sections: - section emptylines - { $$ = $1; } - | section EMPTY_LINE emptylines sections - { $$ = $1; $$->next = $4; } + emptylines section emptylines + { $$ = $2; } + | emptylines section EMPTY_LINE emptylines sections + { $$ = $2; $$->next = $5; } | emptylines { $$ = NULL; } diff --git a/builder/test-virt-index-validate-good-3 b/builder/test-virt-index-validate-good-3 new file mode 100644 index 0000000..f10adf0 --- /dev/null +++ b/builder/test-virt-index-validate-good-3 @@ -0,0 +1,4 @@ +# Empty lines before the first section + +[foo] +key=value diff --git a/builder/test-virt-index-validate.sh b/builder/test-virt-index-validate.sh index c66929d..b00a086 100755 --- a/builder/test-virt-index-validate.sh +++ b/builder/test-virt-index-validate.sh @@ -22,3 +22,4 @@ set -e ! $VG virt-index-validate test-virt-index-validate-bad-1 $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 -- 2.1.0
Richard W.M. Jones
2015-Mar-23 12:52 UTC
Re: [Libguestfs] [PATCH] builder: handle empty lines in indexes before first section (RHBZ#1201526)
ACK. I'll push this shortly. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Seemingly Similar Threads
- [PATCH] builder: allow more empty lines in index files
- [PATCH 1/3] builder: make the C index parser reentrant
- [PATCH 1/2] builder: allow the index parser to parse files with no sections
- [PATCH 0/6] RFC: basic subscription-manager support in virt-customize
- [PATCH 5/5] builder: ignore repositories with download failures