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

Escape package registry information to reduce unreadable files #1505

Closed
gep13 opened this issue Feb 21, 2018 · 0 comments
Closed

Escape package registry information to reduce unreadable files #1505

gep13 opened this issue Feb 21, 2018 · 0 comments

Comments

@gep13
Copy link
Member

gep13 commented Feb 21, 2018

When creating a registry backup, it is possible that Chocolatey creates a file that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<registrySnapshot xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <user>S-1-5-21-2882331601-3999307508-2126793871-124194</user>
  <keys>
    <key installerType="Msi" displayName="ApplicationABC" displayVersion="1.2.3.4">
      <RegistryView>Registry64</RegistryView>
      <KeyPath>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AB12C345-D6EF-78GH-9123-IJ4456KL7M89}</KeyPath>
      <DefaultValue />
      <InstallLocation><![CDATA[C:\Program Files\ApplicationABC]]></InstallLocation>
      <UninstallString><![CDATA[]]></UninstallString>
      <HasQuietUninstall>false</HasQuietUninstall>
      <Publisher><![CDATA[ApplicationABC]]></Publisher>
      <InstallDate>20171109</InstallDate>
      <InstallSource><![CDATA[C:\Users\bob\AppData\Local\Temp\chocolatey\mia3\]]></InstallSource>
      <Language>1033</Language>
      <Version>1234</Version>
      <VersionMajor>1</VersionMajor>
      <VersionMinor>2</VersionMinor>
      <SystemComponent>true</SystemComponent>
      <WindowsInstaller>true</WindowsInstaller>
      <NoRemove>true</NoRemove>
      <NoModify>true</NoModify>
      <NoRepair>true</NoRepair>
      <ReleaseType />
      <ParentKeyName />
      <LocalPackage><![CDATA[C:\Windows\Installer\1da27cf2.msi]]></LocalPackage>
    </key>
    <key installerType="Unknown" displayName="ApplicationABC 1.2.3.4 x64 (Remove only)S$�&#x1E;�&#x6;&#x1A;" displayVersion="1.2.3.4">
      <RegistryView>Registry32</RegistryView>
      <KeyPath>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ApplicationABC 1.2.3.4 x64</KeyPath>
      <DefaultValue />
      <InstallLocation><![CDATA[C:\Program Files\ApplicationABC]]></InstallLocation>
      <UninstallString><![CDATA["C:\ProgramData\{4FAD6CA6-67F3-45F7-85AE-E9B62FDF0BAD}\ApplicationABCInstaller.exe" REMOVE=TRUE MODIFY=FALSE]]></UninstallString>
      <HasQuietUninstall>false</HasQuietUninstall>
      <Publisher><![CDATA[ApplicationABC]]></Publisher>
      <InstallDate />
      <InstallSource><![CDATA[]]></InstallSource>
      <Language />
      <Version />
      <VersionMajor>1</VersionMajor>
      <VersionMinor>2</VersionMinor>
      <SystemComponent>false</SystemComponent>
      <WindowsInstaller>false</WindowsInstaller>
      <NoRemove>false</NoRemove>
      <NoModify>true</NoModify>
      <NoRepair>true</NoRepair>
      <ReleaseType />
      <ParentKeyName />
    </key>
  </keys>
</registrySnapshot>

The additional characters in the Display Name are causing problems when trying to load the registry snapshot again

@gep13 gep13 self-assigned this Feb 21, 2018
@ferventcoder ferventcoder added this to the 0.10.9 milestone Feb 21, 2018
gep13 added a commit to gep13/choco that referenced this issue Feb 22, 2018
- Also, when de-serializing, if a .backup file exists, remove original
- Warn user that .backup file exists and needs to be corrected
gep13 added a commit to gep13/choco that referenced this issue Feb 22, 2018
- Also, when de-serializing, if a .backup file exists, remove original
- Warn user that .backup file exists and needs to be corrected
gep13 added a commit to gep13/choco that referenced this issue Feb 22, 2018
- Also, when de-serializing, if a .backup file exists, remove original
- Warn user that .backup file exists and needs to be corrected
gep13 added a commit to gep13/choco that referenced this issue Feb 23, 2018
- Also, when de-serializing, if a .backup file exists, remove original
- Warn user that .backup file exists and needs to be corrected
gep13 added a commit to gep13/choco that referenced this issue Feb 23, 2018
- Also, when de-serializing, if a .backup file exists, remove original
- Warn user that .backup file exists and needs to be corrected
ferventcoder added a commit that referenced this issue Feb 26, 2018
(GH-1505) Ensure package information from registry is escaped
ferventcoder added a commit that referenced this issue Feb 26, 2018
Keeping in mind this is an XML document and it does have Cdata
elements, give the user an area of concentration.
ferventcoder added a commit that referenced this issue Feb 26, 2018
* stable:
  (GH-1505) clarify where to find invalid characters
  (GH-1415) Added additional check for zip content file
  (GH-1505) Ensure package information is escaped
  (maint) Whitespace changes
@ferventcoder ferventcoder changed the title Package Registry Information may need to be escaped Escape package registry information to reduce unreadable files Mar 4, 2018
ferventcoder added a commit that referenced this issue May 4, 2018
The change made for GH-1505 caused the registry information to escape a
little too well, so some of the quotes and apostrophes were being saved
as `&apos;` and `&quot;`. When it came time for automatic uninstaller
to remove the software that was found in the snapshot, it didn't know
how to work with those escaped double quotes and gave up very quickly.

To fix this, don't escape those two items, but handle any that may have
already had this adjustment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants