Remove URL-unsafe characters from gen-secret charset
Remove ^, +, ~, :, @ from the allowed charset. The ^ character breaks SQLAlchemy DATABASE_URL parsing, + becomes space in URL query strings, : and @ are URL delimiters. The remaining charset (A-Za-z0-9._-) is safe in URLs, database connection strings, YAML, JSON, and shell without any encoding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,12 +57,12 @@ echo
|
||||
|
||||
out=$("$GEN_SECRET" --dryrun 2>&1)
|
||||
assert_eq "dryrun default length" \
|
||||
'[dryrun] Would generate a 32-character secret from charset: [A-Za-z0-9._+\-:@^~]' \
|
||||
'[dryrun] Would generate a 32-character secret from charset: [A-Za-z0-9._\-]' \
|
||||
"$out"
|
||||
|
||||
out=$("$GEN_SECRET" -n 16 2>&1)
|
||||
assert_eq "dryrun custom length" \
|
||||
'[dryrun] Would generate a 16-character secret from charset: [A-Za-z0-9._+\-:@^~]' \
|
||||
'[dryrun] Would generate a 16-character secret from charset: [A-Za-z0-9._\-]' \
|
||||
"$out"
|
||||
|
||||
# --- Help ---
|
||||
@@ -78,7 +78,7 @@ out=$("$GEN_SECRET" 2>&1)
|
||||
rc=$?
|
||||
assert_exit "default exits 0" 0 "$rc"
|
||||
assert_eq "default length is 32" 32 "${#out}"
|
||||
assert_match "default uses safe charset" '^[A-Za-z0-9._+:@^~-]+$' "$out"
|
||||
assert_match "default uses safe charset" '^[A-Za-z0-9._-]+$' "$out"
|
||||
|
||||
# --- Custom length ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user