Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and document registry issues #1635

Merged
merged 5 commits into from
Apr 7, 2017
Merged

Conversation

chris-rock
Copy link
Contributor

Powershell 3 has issues with some characters in strings when used in combination with ConvertTo-Json:

PS C:\Windows\system32> $properties = New-Object -Type PSObject
$properties | Add-Member "super" "\/value/\\"
$properties | ConvertTo-Json
ConvertTo-Json : The converted JSON string is in bad format.
At line:3 char:15
+ $properties | ConvertTo-Json
+               ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (@{super=\/value/\\}:PSObject) 
    [ConvertTo-Json], InvalidOperationException
    + FullyQualifiedErrorId : JsonStringInBadFormat,Microsoft.PowerShell.Comma 
   nds.ConvertToJsonCommand

By using ConvertTo-Json -Compress, it just works:

PS C:\Windows\system32> $properties = New-Object -Type PSObject
$properties | Add-Member "super" "\/value/\\"
$properties | ConvertTo-Json -Compress
{"super":"\\/value/\\\\"}

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
…handled

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
@@ -66,7 +66,10 @@ def initialize(name, reg_key = nil)
# generate registry_key if we do not have a regular expression
@options[:path] = @options[:hive]
# add optional key path
@options[:path] += '\\' + @options[:key] if @options[:key]
if @options[:key]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we break out the building of the path to a private helper method in this class and add some tests to it? There's enough conditional logic in building the path now that I think it's warranted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you @adamleff This would increase the quality!

Broke out some of the conditional logic in the `#initialize`
method into helper methods and added tests.

Signed-off-by: Adam Leff <adam@leff.co>
@chris-rock
Copy link
Contributor Author

Thank you @adamleff for improving my PR.

@adamleff adamleff merged commit b8c397d into master Apr 7, 2017
@adamleff adamleff deleted the chris-rock/fix-regedit-ps branch April 7, 2017 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants