Repository navigation
Commit 6b55379
Escape the database settings written into wp-tests-config.php (#355)
prepare.php copies WPT_DB_NAME, WPT_DB_USER, WPT_DB_PASSWORD, WPT_DB_HOST and
WPT_TABLE_PREFIX into single-quoted PHP strings in wp-tests-config.php without
escaping them.
A password with a single quote, or one ending with a backslash, made the file
a parse error, so the test run failed and cleanup-db.php could not read the
settings. A double backslash was silently written as one.
The values are now escaped with addcslashes( $value, "\\'" ), as WordPress
does when it writes wp-config.php in wp-admin/setup-config.php, and the same
goes for WP_PHP_BINARY. The placeholders are replaced with strtr() in a
single pass: str_replace() ran each pair over the previous result, so a
password containing "localhost" had that part replaced with WPT_DB_HOST.
The CI job now uses a password with a quote, a backslash and the word
"localhost", and checks that DB_PASSWORD in the generated file equals
WPT_DB_PASSWORD. The mysql image puts MYSQL_PASSWORD into SQL unescaped, so a
step sets the password with ALTER USER instead.
Co-authored-by: Amy Kamala <39748136+kittenkamala@users.noreply.github.com>1 parent 549f035 commit 6b55379
2 files changed
Lines changed: 37 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
| |||
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
81 | 98 | | |
82 | 99 | | |
83 | 100 | | |
| |||
91 | 108 | | |
92 | 109 | | |
93 | 110 | | |
94 | | - | |
| 111 | + | |
95 | 112 | | |
96 | 113 | | |
97 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | | - | |
| 392 | + | |
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
399 | 402 | | |
400 | 403 | | |
401 | 404 | | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
407 | 410 | | |
408 | 411 | | |
409 | 412 | | |
410 | 413 | | |
411 | | - | |
412 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
413 | 421 | | |
414 | 422 | | |
415 | 423 | | |
| |||
0 commit comments