Commit 40b3f46
fix: restore SafeURL for DSN parsing with special character passwords (#166)
* test: add tests for DSN parsing with special character passwords
Add comprehensive unit tests covering all database types (postgres, mysql,
mariadb, sqlserver) with passwords containing special characters (@, :, /, #,
?, &, =). These tests currently fail due to regression in commit f3508c0 where
native URL() constructor replaced SafeURL.
Tests verify that DSN strings passed via --dsn CLI flag correctly parse
passwords with unencoded special characters.
* fix: restore SafeURL and fix command line arg parsing for special characters
This commit fixes two related issues with special characters in DSN passwords:
1. Replace native URL() constructor with SafeURL class at line 509 in
src/config/env.ts. This fixes regression introduced in commit f3508c0 where
passwords with unencoded special characters (@, :, /, etc.) were misparsed.
SafeURL correctly handles unencoded special characters by treating everything
between the last colon before @ and the @ symbol as the password, avoiding
URL delimiter conflicts.
2. Fix command line argument parser to split only on first '=' character.
Previously, arg.split('=') would split on ALL '=' characters, causing DSN
strings with '=' in passwords (e.g., my&pass=word) to be incorrectly
truncated. Now uses indexOf() and substring() to preserve everything after
the first '=' as the value.
Fixes all 20 test cases in env-dsn-parsing.test.ts covering postgres, mysql,
mariadb, and sqlserver with various special character combinations.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6afd814 commit 40b3f46
2 files changed
+21
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
334 | 349 | | |
335 | 350 | | |
336 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
503 | 506 | | |
504 | 507 | | |
505 | 508 | | |
506 | | - | |
| 509 | + | |
507 | 510 | | |
508 | | - | |
| 511 | + | |
509 | 512 | | |
510 | 513 | | |
511 | 514 | | |
| |||
0 commit comments