From 855df874403b11ea426c5c6fa708e52ab0b2f042 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 22 Oct 2011 15:48:15 +0100 Subject: [PATCH] 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 --- perl/lib/Win/Hivex/Regedit.pm | 10 +++++----- perl/t/560-regedit-import.t | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) 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 = '[\] -- 1.8.3.1