summaryrefslogtreecommitdiffstats
path: root/components/json_schema/json_schema_validator.h
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:23:46 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:23:46 +0000
commit200799c3b53491d58480edcc82cc332dd5362e1b (patch)
treedc44442df2f116574e3336288d24c6365e2147e3 /components/json_schema/json_schema_validator.h
parenta3cdef6c97123dd2f18697ffda40df6f9bdf5ad4 (diff)
downloadchromium_src-200799c3b53491d58480edcc82cc332dd5362e1b.zip
chromium_src-200799c3b53491d58480edcc82cc332dd5362e1b.tar.gz
chromium_src-200799c3b53491d58480edcc82cc332dd5362e1b.tar.bz2
Ignore unknown attributes when parsing JSON schemas.
JSON schemas are used by extensions that support enterprise management, to declare the policies that they support. The current parser rejects schemas with unknown attributes; this CL lifts that restriction for 2 reasons: - the JSON schema spec does not mandate this behavior for validators - it restricts future extensions to this format BUG=108992 Review URL: https://codereview.chromium.org/94043003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/json_schema/json_schema_validator.h')
-rw-r--r--components/json_schema/json_schema_validator.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/components/json_schema/json_schema_validator.h b/components/json_schema/json_schema_validator.h
index 4584a9d..4e8acad 100644
--- a/components/json_schema/json_schema_validator.h
+++ b/components/json_schema/json_schema_validator.h
@@ -70,6 +70,12 @@ class JSONSchemaValidator {
std::string message;
};
+ enum Options {
+ // Ignore unknown attributes. If this option is not set then unknown
+ // attributes will make the schema validation fail.
+ OPTIONS_IGNORE_UNKNOWN_ATTRIBUTES = 1 << 0,
+ };
+
// Error messages.
static const char kUnknownTypeReference[];
static const char kInvalidChoice[];
@@ -108,6 +114,13 @@ class JSONSchemaValidator {
const std::string& schema,
std::string* error);
+ // Same as above but with |options|, which is a bitwise-OR combination of the
+ // Options above.
+ static scoped_ptr<base::DictionaryValue> IsValidSchema(
+ const std::string& schema,
+ int options,
+ std::string* error);
+
// Creates a validator for the specified schema.
//
// NOTE: This constructor assumes that |schema| is well formed and valid.