Permalink
Browse files

Be lenient about blank lines before headers.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  • Loading branch information...
1 parent 9a1ab49 commit ded7bd65fd0403b505057b759ad35bb19a40655a @rcaputo rcaputo committed with Apr 4, 2010
Showing with 19 additions and 3 deletions.
  1. +18 −2 lib/SVN/Dump/Reader.pm
  2. +1 −1 t/dump/fail/h_empty.svn
View
@@ -35,6 +35,7 @@ sub read_record {
# first get the headers
my $headers = $fh->read_header_block();
+ return unless $headers;
$record->set_headers_block( $headers );
# get the property block
@@ -83,13 +84,28 @@ sub read_record {
sub read_header_block {
my ($fh) = @_;
+ my $in_headers = 0;
+
local $/ = $NL;
my $headers = SVN::Dump::Headers->new();
while(1) {
my $line = <$fh>;
- confess _eof() if !defined $line;
+
+ # EOF is unexpected if we're in headers. Fine if we're not.
+ unless (defined $line) {
+ confess _eof() if $in_headers;
+ last;
+ }
+
chop $line;
- last if $line eq ''; # stop on empty line
+
+ # Empty line ends headers. Discarded if before headers.
+ if ($line eq '') {
+ next unless $in_headers;
+ last;
+ }
+
+ $in_headers = 1;
my ($key, $value) = split /: /, $line, 2;
$headers->{$key} = $value;
View
@@ -1,2 +1,2 @@
read_header_block
-^Unexpected EOF line \d+
+^Empty line found instead of a header block line \d+

0 comments on commit ded7bd6

Please sign in to comment.