aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/connection_types.js3
-rw-r--r--common/misc.js14
-rw-r--r--common/sanitize_JSON.js2
-rw-r--r--common/stored_types.js4
4 files changed, 19 insertions, 4 deletions
diff --git a/common/connection_types.js b/common/connection_types.js
index 41bde75..88c6964 100644
--- a/common/connection_types.js
+++ b/common/connection_types.js
@@ -13,8 +13,7 @@
const CONNECTION_TYPE = {
REMOTE_STORAGE : "0",
PAGE_ACTIONS : "1",
- PAGE_INFO : "2",
- ACTIVITY_INFO : "3"
+ ACTIVITY_INFO : "2"
};
/*
diff --git a/common/misc.js b/common/misc.js
index a59ec14..7158d32 100644
--- a/common/misc.js
+++ b/common/misc.js
@@ -12,6 +12,7 @@
* IMPORT browser
* IMPORT is_chrome
* IMPORT TYPE_NAME
+ * IMPORT TYPE_PREFIX
* IMPORTS_END
*/
@@ -154,6 +155,18 @@ function sign_policy(policy, now, hours_offset) {
return gen_unique(time + policy);
}
+/* Regexes and objest to use as/in schemas for parse_json_with_schema(). */
+const nonempty_string_matcher = /.+/;
+
+const matchers = {
+ sha256: /^[0-9a-f]{64}$/,
+ nonempty_string: nonempty_string_matcher,
+ component: [
+ new RegExp(`^[${TYPE_PREFIX.SCRIPT}${TYPE_PREFIX.BAG}]$`),
+ nonempty_string_matcher
+ ]
+};
+
/*
* EXPORTS_START
* EXPORT gen_nonce
@@ -165,5 +178,6 @@ function sign_policy(policy, now, hours_offset) {
* EXPORT nice_name
* EXPORT open_in_settings
* EXPORT is_privileged_url
+ * EXPORT matchers
* EXPORTS_END
*/
diff --git a/common/sanitize_JSON.js b/common/sanitize_JSON.js
index 8268d3e..8b86d2d 100644
--- a/common/sanitize_JSON.js
+++ b/common/sanitize_JSON.js
@@ -37,7 +37,7 @@ function sanitize_unknown(schema, item)
let _default = undefined;
if (!Array.isArray(schema) || schema[1] === "matchentry" ||
- schema.length < 2 || !["ordefault", "or"].includes(schema))
+ schema.length < 2 || !["ordefault", "or"].includes(schema[1]))
return sanitize_unknown_no_alternatives(schema, item);
if ((schema.length & 1) !== 1) {
diff --git a/common/stored_types.js b/common/stored_types.js
index 304842b..bfceba6 100644
--- a/common/stored_types.js
+++ b/common/stored_types.js
@@ -18,7 +18,9 @@ const TYPE_PREFIX = {
PAGE : "p",
BAG : "b",
SCRIPT : "s",
- VAR : "_"
+ VAR : "_",
+ /* Url prefix is not used in stored settings. */
+ URL : "u"
};
const TYPE_NAME = {