Skip to content

Commit dfbea91

Browse files
committed
forbid non-ASCII characters in the HP_SHARED_KEY
Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
1 parent d97a42f commit dfbea91

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ HaRP is configured via several environment variables. Here are the key variables
161161
- **`HP_SHARED_KEY`** (or **`HP_SHARED_KEY_FILE`**)
162162
- **Description:** A secret token used for authentication between services.
163163
- **Requirement:** Must be set at runtime. Use only one of these methods.
164+
- **Important:** Must contain only ASCII characters (a-z, A-Z, 0-9, and common symbols).
164165

165166
- **`NC_INSTANCE_URL`**
166167
- **Description:** The base URL of your Nextcloud instance.

start.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ if [ -z "$HP_SHARED_KEY" ]; then
9292
echo "ERROR: Either HP_SHARED_KEY or HP_SHARED_KEY_FILE must be set."
9393
exit 1
9494
fi
95+
96+
# Validate HP_SHARED_KEY contains only ASCII characters (required by SPOE library)
97+
NON_ASCII_COUNT=$(printf '%s' "$HP_SHARED_KEY" | LC_ALL=C tr -d '\040-\176' | wc -c)
98+
if [ "$NON_ASCII_COUNT" -gt 0 ]; then
99+
echo "ERROR: HP_SHARED_KEY contains non-ASCII characters."
100+
echo "Please use only printable ASCII characters (a-z, A-Z, 0-9, and symbols like !@#\$%^&*...)."
101+
exit 1
102+
fi
103+
95104
export HP_SHARED_KEY
96105

97106
# Check if the required environment variables are set

0 commit comments

Comments
 (0)