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 ' ;
8
10
PDOTest::skip ();
@@ -15,14 +17,16 @@ $dsnWithCredentials = $config['ENV']['PDOTEST_DSN'];
15
17
$ user = $ config ['ENV ' ]['PDOTEST_USER ' ] ?? null ;
16
18
$ password = $ config ['ENV ' ]['PDOTEST_PASS ' ] ?? null ;
17
19
if (!$ user ) {
18
- preg_match ('/user=(. *?) / ' , $ dsnWithCredentials , $ match );
19
- $ user = $ match [1 ] ?? '' ;
20
+ preg_match ('/user=([^ ] *?) / ' , $ dsnWithCredentials , $ match );
21
+ $ user = $ match [1 ] ?? null ;
20
22
}
21
23
if (!$ password ) {
22
- preg_match ('/password=(. *?) / ' , $ dsnWithCredentials , $ match );
23
- $ password = $ match [1 ] ?? '' ;
24
+ preg_match ('/password=([^ ] *?)/ ' , $ dsnWithCredentials , $ match );
25
+ $ password = $ match [1 ] ?? null ;
24
26
}
25
- $ dsn = str_replace (" user= {$ user } password= {$ password }" , '' , $ dsnWithCredentials );
27
+ $ dsn = str_replace ("user= {$ user }" , '' , $ dsnWithCredentials );
28
+ $ dsn = str_replace ("password= {$ password }" , '' , $ dsn );
29
+ $ dsn = rtrim ($ dsn );
26
30
27
31
echo "dsn without credentials / correct user / correct password \n" ;
28
32
try {
0 commit comments