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 for Loading Invalid Manifests #538

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/WingetCreateCore/Common/PackageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,11 @@ private static bool ParseExeInstallerType(string path, Installer baseInstaller,
{
try
{
ManifestResource rc = new ManifestResource();
XmlDocument manifest = GetManifest(path);
InstallerType? installerTypeEnum;
try
{
rc.LoadFrom(path);
string installerType = rc.Manifest.DocumentElement
string installerType = manifest?.DocumentElement?
.GetElementsByTagName("description")
.Cast<XmlNode>()
.FirstOrDefault()?
Expand Down Expand Up @@ -1109,5 +1108,26 @@ private static string RemoveInvalidCharsFromString(string value)
{
return Regex.Replace(value, InvalidCharacters, string.Empty);
}

/// <summary>
/// Gets the manifest from the specified path.</summary>
/// <param name="path">The path to the manifest.</param>
/// <returns>XmlDocument of the manifest.</returns>
private static XmlDocument GetManifest(string path)
{
var rc = new ManifestResource();
var manifest = new XmlDocument();

try
{
rc.LoadFrom(path);
manifest = rc.Manifest;
}
catch (Exception ex)
{
}

return manifest;
}
}
}