aboutsummaryrefslogtreecommitdiff
path: root/upload_amo.sh
diff options
context:
space:
mode:
Diffstat (limited to 'upload_amo.sh')
-rwxr-xr-xupload_amo.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/upload_amo.sh b/upload_amo.sh
index 71e12ca..3739c9c 100755
--- a/upload_amo.sh
+++ b/upload_amo.sh
@@ -23,6 +23,27 @@ API_KEY="$2"
SECRET="$3"
XPI_PATH="$4"
+escape_regex_special() {
+ printf %s "$1" | sed 's/\([]\.*[-]\)/\\\1/g'
+}
+
+# Note: We don't actually parse JSON. We extract needed keys with sed regexes
+# which does not work in the general case but is sufficient for now.
+_get_json_key() {
+ local KEY_REG="$(escape_regex_special "$1")"
+ printf %s "$2" |
+ awk '{printf "%s", $0}' |
+ sed 's/^.*\("'"$KEY_REG"'"[[:space:]]*:[[:space:]]*"\([^"]*\)"\).*$/\2/'
+}
+
+get_json_key() {
+ local JSON="$2"
+ local VALUE="$(_get_json_key "$@")"
+ if [ "x$VALUE" != "x$JSON" ]; then
+ printf %s "$VALUE"
+ fi
+}
+
base64url() {
printf %s "$1" | base64 -w 0 | tr '/+' '_-' | tr -d '='
}