Commit aabed6d6 authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Allow '$' characters in custom installer attributes.

Bug: 1029787
Change-Id: I1f30a649fcaa7deeb62a1f0b168c89e7555dad5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1946146
Auto-Submit: Joshua Pawlicki <waffles@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720532}
parent 40648da0
......@@ -103,7 +103,7 @@ class ComponentInstallerPolicy {
// rules when issuing an update response.
// Valid values for the name part of an attribute match
// ^[-_a-zA-Z0-9]{1,256}$ and valid values the value part of an attribute
// match ^[-.,;+_=a-zA-Z0-9]{0,256}$ .
// match ^[-.,;+_=$a-zA-Z0-9]{0,256}$ .
virtual update_client::InstallerAttributes GetInstallerAttributes() const = 0;
};
......
......@@ -262,7 +262,7 @@ struct CrxComponent {
// Optional.
// Valid values for the name part of an attribute match
// ^[-_a-zA-Z0-9]{1,256}$ and valid values the value part of an attribute
// match ^[-.,;+_=a-zA-Z0-9]{0,256}$ .
// match ^[-.,;+_=$a-zA-Z0-9]{0,256}$ .
InstallerAttributes installer_attributes;
// Specifies that the CRX can be background-downloaded in some cases.
......
......@@ -122,9 +122,9 @@ bool IsValidInstallerAttributeName(const std::string& name) {
return IsValidInstallerAttributePart(name, "-_", 1, 256);
}
// Returns true if the |value| parameter matches ^[-.,;+_=a-zA-Z0-9]{0,256}$ .
// Returns true if the |value| parameter matches ^[-.,;+_=$a-zA-Z0-9]{0,256}$ .
bool IsValidInstallerAttributeValue(const std::string& value) {
return IsValidInstallerAttributePart(value, "-.,;+_=", 0, 256);
return IsValidInstallerAttributePart(value, "-.,;+_=$", 0, 256);
}
bool IsValidInstallerAttribute(const InstallerAttribute& attr) {
......
......@@ -60,7 +60,7 @@ bool IsValidBrand(const std::string& brand);
// Returns true if the name part of the |attr| parameter matches
// ^[-_a-zA-Z0-9]{1,256}$ and the value part of the |attr| parameter
// matches ^[-.,;+_=a-zA-Z0-9]{0,256}$ .
// matches ^[-.,;+_=$a-zA-Z0-9]{0,256}$ .
bool IsValidInstallerAttribute(const InstallerAttribute& attr);
// Removes the unsecure urls in the |urls| parameter.
......
......@@ -119,7 +119,7 @@ TEST(UpdateClientUtils, IsValidInstallerAttributeName) {
}
// Tests that the value of an InstallerAttribute matches
// ^[-.,;+_=a-zA-Z0-9]{0,256}$
// ^[-.,;+_=$a-zA-Z0-9]{0,256}$
TEST(UpdateClientUtils, IsValidInstallerAttributeValue) {
// Test the length boundaries.
EXPECT_TRUE(IsValidInstallerAttribute(
......@@ -129,8 +129,8 @@ TEST(UpdateClientUtils, IsValidInstallerAttributeValue) {
EXPECT_FALSE(IsValidInstallerAttribute(
make_pair(std::string("name"), std::string(257, 'a'))));
const char* const valid_values[] = {"", "a=1", "A", "Z", "a",
"z", "0", "9", "-.,;+_="};
const char* const valid_values[] = {"", "a=1", "A", "Z", "a",
"z", "0", "9", "-.,;+_=$"};
for (const char* value : valid_values)
EXPECT_TRUE(IsValidInstallerAttribute(
make_pair(std::string("name"), std::string(value))));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment