From: Richard W.M. Jones Date: Sat, 22 Oct 2011 14:48:15 +0000 (+0100) Subject: regedit: Fix syntax for deleting registry keys (RHBZ#737944). X-Git-Tag: 1.3.2~1 X-Git-Url: http://git.annexia.org/?p=hivex.git;a=commitdiff_plain;h=855df874403b11ea426c5c6fa708e52ab0b2f042 regedit: Fix syntax for deleting registry keys (RHBZ#737944). Previously we parsed -[...] to delete a registry key, but this is not correct. It should be [-...]. Reference: http://support.microsoft.com/kb/310516 https://secure.wikimedia.org/wikipedia/en/wiki/Windows_Registry#.REG_files --- diff --git a/perl/lib/Win/Hivex/Regedit.pm b/perl/lib/Win/Hivex/Regedit.pm index 3d7e5ed..8914f9e 100644 --- a/perl/lib/Win/Hivex/Regedit.pm +++ b/perl/lib/Win/Hivex/Regedit.pm @@ -164,16 +164,16 @@ sub reg_import # Ignore comments. next if /^\s*;/; - # Expect to see [...] or -[...] + # Expect to see [...] or [-...] # to merge or delete a node respectively. - if (/^\[(.*)\]\s*$/) { + if (/^\[-(.*)\]\s*$/) { + _delete_node ($hmap, \%params, $1); + $state = "outer"; + } elsif (/^\[(.*)\]\s*$/) { $state = "inner"; $newnode = $1; @newvalues = (); @delvalues = (); - } elsif (/^-\[(.*)\]\s*$/) { - _delete_node ($hmap, \%params, $1); - $state = "outer"; } else { croak (_unexpected ($_, $lineno)); } diff --git a/perl/t/560-regedit-import.t b/perl/t/560-regedit-import.t index 0dca8df..effb024 100644 --- a/perl/t/560-regedit-import.t +++ b/perl/t/560-regedit-import.t @@ -66,7 +66,7 @@ $data = ' [\A] @="Hello" --[\B] +[-\B] '; $expected = '[\] @@ -87,7 +87,7 @@ $data = ' [\A] @=- --[\C] +[-\C] [\A\B] '; @@ -131,7 +131,7 @@ $data = ' "Key\"Containing\"Quotes"=- "ValueContainingEscapes"=- --[\A] +[-\A] '; $expected = '[\]