fix(installer): validate MSI keys and preserve known-folder roots

This commit is contained in:
skylar committed 2026-11-12 15:35:40 -06:00
1 parent ce35620db8
commit 5142691bb2
2 files changed
+16 -1

No files matched your search

+7 -1
View File
@@ -45,6 +45,12 @@ function Get-DirectoryPath($Directories, [string] $Id) {
}
$steps++
if ($steps -gt 256) { throw "Cleanup policy: the Directory table chain for '$Id' does not terminate." }
# Standard directory rows often have DefaultDir='.'. Keep the owned known-folder root
# distinct from DesktopFolder and other roots that otherwise flatten to SourceDir.
if ($current -eq 'LocalAppDataFolder') {
$segments = @('[LocalAppDataFolder]') + $segments
break
}
$parent = [string]$Directories[$current][0]
$name = [string]$Directories[$current][1]
# Directory.DefaultDir is a name, a 'short|long' pair, a 'target:source' pair, or '.' for the
@@ -94,7 +100,7 @@ function Assert-CleanupPolicy($Database, $Directories, [string] $InstallRoot) {
$tables = @(Read-Rows $Database 'SELECT `Name` FROM `_Tables`' 1 | ForEach-Object { $_[0] })
$removeRows = @()
if ('RemoveFile' -in $tables) {
$removeRows = @(Read-Rows $Database 'SELECT `RemoveFile`, `Component_`, `DirProperty`, `FileName`, `InstallMode` FROM `RemoveFile`' 5)
$removeRows = @(Read-Rows $Database 'SELECT `FileKey`, `Component_`, `DirProperty`, `FileName`, `InstallMode` FROM `RemoveFile`' 5)
}
$components = @{}
foreach ($row in (Read-Rows $Database 'SELECT `Component` FROM `Component`' 1)) { $components[[string]$row[0]] = $true }
@@ -226,6 +226,15 @@ $nl = if ($authoring.Contains("`r`n")) { "`r`n" } else { "`n" }
$suiteRow = ' <RemoveFolder Id="RemoveSuiteFolder" Directory="CraftSuiteFolder" On="uninstall" />'
$appRow = ' <RemoveFolder Id="RemoveInstallFolder" Directory="INSTALLFOLDER" On="uninstall" />'
$mutations = @(
@{
Name = 'same-relative-path-under-another-root'
Why = 'a matching Programs/ArtCraft/Launcher suffix under DesktopFolder is not the owned LocalAppDataFolder path'
Expect = 'not one of the folders this MSI creates'
Pairs = @(
@{ From = ' <StandardDirectory Id="DesktopFolder" />'; To = ' <StandardDirectory Id="DesktopFolder"><Directory Id="OtherPrograms" Name="Programs"><Directory Id="OtherSuite" Name="ArtCraft"><Directory Id="OtherInstall" Name="Launcher" /></Directory></Directory></StandardDirectory>' },
@{ From = $suiteRow; To = $suiteRow + $nl + ' <RemoveFolder Id="RemoveOtherRoot" Directory="OtherInstall" On="uninstall" />' }
)
},
@{
Name = 'shared-programs-row'
Why = 'the #584 row returns, so uninstall would remove the shared %LOCALAPPDATA%\Programs folder'