winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit aa9beac34f35fa5406eb9927a3046ef6eedbb7fc
parent 9d3d2202ac19b167ad6dff4e38fd80d15ccd51e2
Author: yao-msft <50888816+yao-msft@users.noreply.github.com>
Date:   Fri,  8 May 2020 22:16:40 -0700

Relax Version validation (#114)


Diffstat:
Msrc/AppInstallerCLITests/TestData/Manifest-Bad-VersionInvalid.yaml | 2+-
Msrc/AppInstallerCLITests/TestData/Manifest-Good-Minimum.yaml | 2+-
Msrc/AppInstallerRepositoryCore/Manifest/Manifest.cpp | 12+++++++++++-
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/AppInstallerCLITests/TestData/Manifest-Bad-VersionInvalid.yaml b/src/AppInstallerCLITests/TestData/Manifest-Bad-VersionInvalid.yaml @@ -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: diff --git a/src/AppInstallerCLITests/TestData/Manifest-Good-Minimum.yaml b/src/AppInstallerCLITests/TestData/Manifest-Good-Minimum.yaml @@ -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: diff --git a/src/AppInstallerRepositoryCore/Manifest/Manifest.cpp b/src/AppInstallerRepositoryCore/Manifest/Manifest.cpp @@ -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); } }, @@ -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)