Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

A database password with a quote or a backslash breaks wp-tests-config.php

Aperta
#354 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@ekamran ci sta già lavorando.

Dal 12/10/2026.

  • #355 di @ekamran — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
php
Ambito
testing, tooling

Direzione di ricerca

Start by reading prepare.php where it writes wp-tests-config.php, then compare its value escaping with wp-admin/setup-config.php as described in the issue. Check the generated config with quote, backslash, and localhost-containing values, and verify that the table prefix is handled too. Done means generated settings preserve the supplied values and the test run and cleanup can read the config; a pull request is already open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

prepare.php writes WPT_DB_NAME, WPT_DB_USER, WPT_DB_PASSWORD and WPT_DB_HOST into single-quoted PHP strings in wp-tests-config.php without escaping them.

I ran the config-writing code of prepare.php on master (61491cb) with a few passwords:

WPT_DB_PASSWORD Result in wp-tests-config.php
p'q"r$s#t u Parse error on line 42
endswith\ Parse error on line 43
two\\back No error, but DB_PASSWORD is two\back
my-localhost-pw No error, but DB_PASSWORD is my-127.0.0.1:33348-pw

The last one happens because the placeholders are replaced one after another with str_replace(), so the localhost placeholder also matches inside the password that was written a step earlier.

The same escaping problem applies to WPT_TABLE_PREFIX, which is written into $table_prefix in the generated config.

With the parse error, the test run fails, and cleanup-db.php cannot read the settings, so the test tables stay in the database. Randomly generated passwords can contain these characters.

WordPress escapes these values with addcslashes( $value, "\\'" ) when it writes wp-config.php in wp-admin/setup-config.php. I have a fix with a CI check and will open a pull request.

Lingua principale
PHP
Stelle
77
Fork
79
Merge medio
4g 19h
PR unite (30g)
3

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di WordPress/phpunit-test-runner

Tutte le issue di WordPress/phpunit-test-runner

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.