From 048815121720c9cfb0bc8df48efd9aa0c846e3d0 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Mon, 2 Jun 2008 14:11:53 -0700 Subject: [PATCH] Hypens are allowed as key names in RFC822-style data. Update the parsers for the RFC822-style key-value lists. Allow a hyphen in key names. Previously, the "Backup-Intent" field was being ignored because its name was considered invalid; this change should fix that. --- contrib/clean-segments.pl | 2 +- contrib/restore.pl | 4 ++-- lbs.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/clean-segments.pl b/contrib/clean-segments.pl index 5af3ae3..8f9aa80 100755 --- a/contrib/clean-segments.pl +++ b/contrib/clean-segments.pl @@ -31,7 +31,7 @@ foreach (glob "*.lbs") { while (defined($line = )) { chomp $line; - if ($line =~ m/^(\w+):\s*(.*)$/) { + if ($line =~ m/^([-\w]+):\s*(.*)$/) { $descriptor{$1} = $2; $last_key = $1; } elsif ($line =~/^\s/ && defined $last_key) { diff --git a/contrib/restore.pl b/contrib/restore.pl index 5562974..98ae277 100755 --- a/contrib/restore.pl +++ b/contrib/restore.pl @@ -359,7 +359,7 @@ sub process_metadata { # Try to parse the data as "key: value" pairs of file metadata. Also # handle continuation lines, which start with whitespace and continue # the previous "key: value" pair. - if ($line =~ m/^(\w+):\s*(.*)$/) { + if ($line =~ m/^([-\w]+):\s*(.*)$/) { $info{$1} = $2; $last_key = $1; } elsif ($line =~/^\s/ && defined $last_key) { @@ -409,7 +409,7 @@ while (defined($line = )) { # lines. chomp $line; - if ($line =~ m/^(\w+):\s*(.*)$/) { + if ($line =~ m/^([-\w]+):\s*(.*)$/) { $descriptor{$1} = $2; $last_key = $1; } elsif ($line =~/^\s/ && defined $last_key) { diff --git a/lbs.py b/lbs.py index 392bb04..507b9e1 100644 --- a/lbs.py +++ b/lbs.py @@ -263,7 +263,7 @@ def parse(lines, terminate=None): last_key = None continue - m = re.match(r"^(\w+):\s*(.*)$", l) + m = re.match(r"^([-\w]+):\s*(.*)$", l) if m: dict[m.group(1)] = m.group(2) last_key = m.group(1) -- 2.20.1