Skip to content

Commit

Permalink
Relax Version validation (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
yao-msft authored May 9, 2020
1 parent 9d3d220 commit aa9beac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Bad manifest. Invalid version
Id: microsoft.msixsdk
Name: MSIX SDK
Version: Not.A.Version
Version: 1.0.9-/
Publisher: Microsoft
InstallerType: Zip
Installers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Minimum required
Id: microsoft.msixsdk
Name: MSIX SDK
Version: 1.7.32
Version: 1.07.32-beta
Publisher: Microsoft
InstallerType: Zip
Installers:
Expand Down
12 changes: 11 additions & 1 deletion src/AppInstallerRepositoryCore/Manifest/Manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace AppInstaller::Manifest
{ "Id", [this](const YAML::Node& value) { Id = value.as<std::string>(); Utility::Trim(Id); }, true, "^[\\S]+\\.[\\S]+$" },
{ "Name", [this](const YAML::Node& value) { Name = value.as<std::string>(); Utility::Trim(Name); }, true },
{ "Version", [this](const YAML::Node& value) { Version = value.as<std::string>(); Utility::Trim(Version); }, true,
"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){0,3}$" },
/* File name chars not allowed */ "^[^\\\\/:\\*\\?\"<>\\|\\x01-\\x1f]+$" },
{ "Publisher", [this](const YAML::Node& value) { Publisher = value.as<std::string>(); }, true },
{ "AppMoniker", [this](const YAML::Node& value) { AppMoniker = value.as<std::string>(); Utility::Trim(AppMoniker); } },
{ "Channel", [this](const YAML::Node& value) { Channel = value.as<std::string>(); Utility::Trim(Channel); } },
Expand Down Expand Up @@ -151,6 +151,16 @@ namespace AppInstaller::Manifest
resultErrors.emplace_back(ManifestError::FieldNotSupported, "Channel", Channel);
}

try
{
// Version value should be successfully parsed
Utility::Version test{ Version };
}
catch (const std::exception&)
{
resultErrors.emplace_back(ManifestError::InvalidFieldValue, "Version", Version);
}

// Check duplicate installer entry. {installerType, arch, language and scope} combination is the key.
// Todo: use the comparator from ManifestComparator when that one is fully implemented.
auto installerCmp = [](const ManifestInstaller& in1, const ManifestInstaller& in2)
Expand Down

0 comments on commit aa9beac

Please sign in to comment.