Skip to content

Commit

Permalink
(GH-1490) Remove quotes/apostrophes surrounding parameter
Browse files Browse the repository at this point in the history
It was noted that there is a discrepancy with how the built-in
`Get-PackageParameters` behaves differently and in an incompatible way
as compared to the the core extension's old version of
`Get-PackageParameters`. The built-in Get-PackageParameters should do at
least what core extension does and then enhance on that with more.

To remove the noted incompatibility, it should handle quotes and
apostrophes surrounding the items in the same way, which is to remove
them as it loads the parameter values into the hash table.
  • Loading branch information
ferventcoder committed Feb 20, 2018
1 parent c96218f commit 5d95849
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ compatibility with `chocolatey-core.extension`, use `:`.
For example `-Parameters "/ITEM1:value /ITEM2:value with spaces"
NOTE: In 0.10.9+, to maintain compatibility with the prior art of the
chocolatey-core.extension method, quotes and apostrophes surrounding
parameter values will be removed. When the param is used, those items
can be added back if desired, but it's most important to ensure that
existing packages are compatible on upgrade.
.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply and future expansion.
Do not use directly.
Expand Down Expand Up @@ -144,7 +150,7 @@ param(
foreach ($paramString in $paramStrings) {
if (!$paramString -or $paramString -eq '') { continue }

Select-String '(?:^|\s+)\/(?<ItemKey>[^\:\=\s)]+)(?:(?:\:|=){1}(?<ItemValue>.*?)(?:(?=\s+\/)|$))?' -Input $paramString -AllMatches | % { $_.Matches } | % {
Select-String '(?:^|\s+)\/(?<ItemKey>[^\:\=\s)]+)(?:(?:\:|=){1}(?:\''|\"){0,1}(?<ItemValue>.*?)(?:\''|\"){0,1}(?:(?=\s+\/)|$))?' -Input $paramString -AllMatches | % { $_.Matches } | % {
if (!$_) { continue } #Posh v2 issue?
$paramItemName = ($_.Groups["ItemKey"].Value).Trim()
$paramItemValue = ($_.Groups["ItemValue"].Value).Trim()
Expand Down

0 comments on commit 5d95849

Please sign in to comment.