Skip to content

Commit 4dd2cfd

Browse files
authored
fix(core): Add 'PSObject.Copy()' to 'substitute()' (#5962)
1 parent a5bd229 commit 4dd2cfd

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
- **json:** Serialize jsonpath return ([#5921](https://github.com/ScoopInstaller/Scoop/issues/5921))
1111
- **scoop-search:** Catch error of parsing invalid manifest ([#5930](https://github.com/ScoopInstaller/Scoop/issues/5930))
12-
- **autoupdate:** Copy `PSCustomObject`-type properties within `autoupdate` to prevent reference changes ([#5934](https://github.com/ScoopInstaller/Scoop/issues/5934))
12+
- **autoupdate:** Copy `PSCustomObject`-type properties within `substitute()` to prevent reference changes ([#5934](https://github.com/ScoopInstaller/Scoop/issues/5934), [#5962](https://github.com/ScoopInstaller/Scoop/issues/5962))
1313
- **system:** Fix argument passing to `Split-PathLikeEnvVar()` in deprecated `strip_path()` ([#5937](https://github.com/ScoopInstaller/Scoop/issues/5937))
1414
- **scoop-cache:** Fix regression in 36026f18 ([#5944](https://github.com/ScoopInstaller/Scoop/issues/5944))
1515
- **core:** Fix "Invoke-ExternalCommand" quoting rules ([#5945](https://github.com/ScoopInstaller/Scoop/issues/5945))

lib/autoupdate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ function Update-ManifestProperty {
365365
}
366366
} elseif ($Manifest.$currentProperty -and $Manifest.autoupdate.$currentProperty) {
367367
# Update other property (global)
368-
$autoupdateProperty = $Manifest.autoupdate.$currentProperty.PSObject.Copy()
368+
$autoupdateProperty = $Manifest.autoupdate.$currentProperty
369369
$newValue = substitute $autoupdateProperty $Substitutions
370370
if (($autoupdateProperty.GetType().Name -eq 'Object[]') -and ($autoupdateProperty.Length -eq 1)) {
371371
# Make sure it's an array

lib/core.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,8 @@ function Test-ScoopCoreOnHold() {
12501250
}
12511251

12521252
function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
1253-
$newentity = $entity
1254-
if ($null -ne $newentity) {
1253+
if ($null -ne $entity) {
1254+
$newentity = $entity.PSObject.Copy()
12551255
switch ($entity.GetType().Name) {
12561256
'String' {
12571257
$params.GetEnumerator() | ForEach-Object {
@@ -1263,7 +1263,7 @@ function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
12631263
}
12641264
}
12651265
'Object[]' {
1266-
$newentity = $entity | ForEach-Object { ,(substitute $_ $params $regexEscape) }
1266+
$newentity = $entity | ForEach-Object { , (substitute $_ $params $regexEscape) }
12671267
}
12681268
'PSCustomObject' {
12691269
$newentity.PSObject.Properties | ForEach-Object { $_.Value = substitute $_.Value $params $regexEscape }

0 commit comments

Comments
 (0)