diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj index 4051f4c994..cfa2a0bbe5 100644 --- a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj +++ b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj @@ -707,6 +707,9 @@ true + + true + true diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters index f29961ab30..187dafc12a 100644 --- a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters +++ b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters @@ -660,6 +660,9 @@ TestData + + TestData + TestData diff --git a/src/AppInstallerCLITests/TestData/Manifest-Good-InstallerUrl-BlockScalar.yaml b/src/AppInstallerCLITests/TestData/Manifest-Good-InstallerUrl-BlockScalar.yaml new file mode 100644 index 0000000000..a36e3ef3c1 --- /dev/null +++ b/src/AppInstallerCLITests/TestData/Manifest-Good-InstallerUrl-BlockScalar.yaml @@ -0,0 +1,17 @@ +# yaml-language-server: $schema=https://aka.ms/winget-manifest.singleton.1.1.0.schema.json + +PackageIdentifier: microsoft.msixsdk +PackageName: MSIX SDK +PackageVersion: 1.07.32-beta +Publisher: Microsoft +ShortDescription: description +License: Test +PackageLocale: en-US +Installers: + - Architecture: x86 + InstallerUrl: > + https://ThisIsNotUsed + InstallerSha256: 98B67758CEAFFCBB3FE47838FD0A8D7BD581C2650842D6B2B0E0D49A23270CCD + InstallerType: msi +ManifestType: singleton +ManifestVersion: 1.1.0 diff --git a/src/AppInstallerCLITests/YamlManifest.cpp b/src/AppInstallerCLITests/YamlManifest.cpp index f893881f83..e00a467d9f 100644 --- a/src/AppInstallerCLITests/YamlManifest.cpp +++ b/src/AppInstallerCLITests/YamlManifest.cpp @@ -958,6 +958,15 @@ TEST_CASE("ReadGoodManifestWithSpaces", "[ManifestValidation]") REQUIRE(manifest.DefaultInstallerInfo.FileExtensions == MultiValue{ "appx", "appxbundle", "msix", "msixbundle" }); } +TEST_CASE("ReadGoodManifestInstallerUrlBlockScalar", "[ManifestValidation]") +{ + ManifestValidateOption validateOption = GetTestManifestValidateOption(); + Manifest manifest = YamlParser::CreateFromPath(TestDataFile("Manifest-Good-InstallerUrl-BlockScalar.yaml"), validateOption); + + REQUIRE(manifest.Installers.size() == 1); + REQUIRE(manifest.Installers[0].Url == "https://ThisIsNotUsed\n"); +} + TEST_CASE("ReadGoodManifests", "[ManifestValidation]") { ManifestTestCase TestCases[] = @@ -973,6 +982,7 @@ TEST_CASE("ReadGoodManifests", "[ManifestValidation]") { "Manifest-Good-Minimum-InstallerType.yaml" }, { "Manifest-Good-Switches.yaml" }, { "Manifest-Good-DefaultExpectedReturnCodeInInstallerSuccessCodes.yaml" }, + { "Manifest-Good-InstallerUrl-BlockScalar.yaml" }, { "Manifest-Good-InstallerTypeZip-PortableExe.yaml" }, { "Manifest-Good-InstallerTypeZip-PortableExeUppercase.yaml" }, }; diff --git a/src/AppInstallerSharedLib/JsonSchemaValidation.cpp b/src/AppInstallerSharedLib/JsonSchemaValidation.cpp index 6cd43450ff..acd339be47 100644 --- a/src/AppInstallerSharedLib/JsonSchemaValidation.cpp +++ b/src/AppInstallerSharedLib/JsonSchemaValidation.cpp @@ -4,8 +4,29 @@ #include "winget/JsonSchemaValidation.h" #include "winget/Resources.h" +#include + namespace AppInstaller::JsonSchema { + namespace + { + struct MultilineRegexEngine + { + explicit MultilineRegexEngine(const std::string& pattern) : + Regex(pattern, std::regex_constants::ECMAScript | std::regex_constants::multiline) + { + } + + static bool search(const std::string& target, const MultilineRegexEngine& expression) + { + return std::regex_search(target, expression.Regex); + } + + private: + std::regex Regex; + }; + } + Json::Value LoadSchemaDoc(std::string_view schemaStr) { Json::Value schemaJson; @@ -35,7 +56,7 @@ namespace AppInstaller::JsonSchema bool Validate(const valijson::Schema& schema, const Json::Value& json, valijson::ValidationResults& results) { - valijson::Validator schemaValidator; + valijson::ValidatorT schemaValidator; valijson::adapters::JsonCppAdapter jsonAdapter(json); return schemaValidator.validate(schema, jsonAdapter, &results); } @@ -59,4 +80,4 @@ namespace AppInstaller::JsonSchema return ss.str(); } -} \ No newline at end of file +}