1
1
--TEST--
2
2
GitHub #12424 (Fix GH-12423: [pdo_pgsql] Changed to prioritize DSN authentication information over arguments.)
3
+ --EXTENSIONS--
4
+ pdo
5
+ pdo_pgsql
3
6
--SKIPIF--
4
7
<?php
5
- if (!extension_loaded ('pdo ' ) || !extension_loaded ('pdo_pgsql ' )) die ('skip not loaded ' );
6
8
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc ' ;
7
9
require __DIR__ . '/config.inc ' ;
10
+ if (strpos ($ config ['ENV ' ]['PDOTEST_DSN ' ], 'password= ' ) === false && !isset ($ config ['ENV ' ]['PDOTEST_PASS ' ])) {
11
+ die ('skip: no password ' );
12
+ }
8
13
PDOTest::skip ();
9
14
?>
10
15
--FILE--
@@ -15,14 +20,16 @@ $dsnWithCredentials = $config['ENV']['PDOTEST_DSN'];
15
20
$ user = $ config ['ENV ' ]['PDOTEST_USER ' ] ?? null ;
16
21
$ password = $ config ['ENV ' ]['PDOTEST_PASS ' ] ?? null ;
17
22
if (!$ user ) {
18
- preg_match ('/user=(. *?) / ' , $ dsnWithCredentials , $ match );
23
+ preg_match ('/user=([^ ] *?)/ ' , $ dsnWithCredentials , $ match );
19
24
$ user = $ match [1 ] ?? '' ;
20
25
}
21
26
if (!$ password ) {
22
- preg_match ('/password=(. *?)$ / ' , $ dsnWithCredentials , $ match );
27
+ preg_match ('/password=([^ ] *?)/ ' , $ dsnWithCredentials , $ match );
23
28
$ password = $ match [1 ] ?? '' ;
24
29
}
25
- $ dsn = str_replace (" user= {$ user } password= {$ password }" , '' , $ dsnWithCredentials );
30
+ $ dsn = str_replace ("user= {$ user }" , '' , $ dsnWithCredentials );
31
+ $ dsn = str_replace ("password= {$ password }" , '' , $ dsn );
32
+ $ dsn = rtrim ($ dsn );
26
33
27
34
echo "dsn without credentials / correct user / correct password \n" ;
28
35
try {
0 commit comments