@@ -123,23 +123,23 @@ if [ "$NON_ASCII_COUNT" -gt 0 ]; then
123123 exit 1
124124fi
125125
126- # Reject characters that break the generated FRP TOML config or get mangled by
127- # strip_quotes:
128- # " - terminates the TOML basic string used for metadatas.token
126+ # Strip surrounding quotes if user accidentally included them in env vars
127+ HP_SHARED_KEY=" $( strip_quotes " $HP_SHARED_KEY " ) "
128+ export HP_SHARED_KEY
129+
130+ # After stripping any surrounding quotes, the remaining value must not contain
131+ # characters that would corrupt the generated FRP TOML config line
132+ # `metadatas.token = "..."`:
133+ # " - terminates the TOML basic string
129134# \ - starts a TOML escape sequence inside that string
130- # ' - silently stripped from the end of the value by strip_quotes() below
131- FORBIDDEN_COUNT=$( printf ' %s' " $HP_SHARED_KEY " | LC_ALL=C tr -cd " \"\\\\ '" | wc -c)
135+ FORBIDDEN_COUNT=$( printf ' %s' " $HP_SHARED_KEY " | LC_ALL=C tr -cd ' "\\' | wc -c)
132136if [ " $FORBIDDEN_COUNT " -gt 0 ]; then
133137 echo " ERROR: HP_SHARED_KEY contains a forbidden character."
134- echo " The following characters are not allowed: double quote (\" ), single quote ('), backslash (\\ )."
138+ echo " The following characters are not allowed: double quote (\" ), backslash (\\ )."
135139 echo " Please choose a password without these characters."
136140 exit 1
137141fi
138142
139- # Strip surrounding quotes if user accidentally included them in env vars
140- HP_SHARED_KEY=" $( strip_quotes " $HP_SHARED_KEY " ) "
141- export HP_SHARED_KEY
142-
143143# Strip surrounding quotes from other commonly affected environment variables
144144NC_INSTANCE_URL=" $( strip_quotes " $NC_INSTANCE_URL " ) "
145145HP_FRP_ADDRESS=" $( strip_quotes " $HP_FRP_ADDRESS " ) "
0 commit comments