File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -207,9 +207,8 @@ public static function parseDsn($dsn)
207
207
$ database = intval (preg_replace ('/[^0-9]/ ' , '' , $ parts ['path ' ]));
208
208
}
209
209
210
- // Extract any 'user' and 'pass' values
210
+ // Extract any 'user' values
211
211
$ user = isset ($ parts ['user ' ]) ? $ parts ['user ' ] : false ;
212
- $ pass = isset ($ parts ['pass ' ]) ? $ parts ['pass ' ] : false ;
213
212
214
213
// Convert the query string into an associative array
215
214
$ options = array ();
@@ -218,6 +217,20 @@ public static function parseDsn($dsn)
218
217
parse_str ($ parts ['query ' ], $ options );
219
218
}
220
219
220
+ //check 'password-encoding' parameter and extracting password based on encoding
221
+ if ($ options && isset ($ options ['password-encoding ' ]) && $ options ['password-encoding ' ] === 'u ' ){
222
+ //extracting urlencoded password
223
+ $ pass = isset ($ parts ['pass ' ]) ? urldecode ($ parts ['pass ' ]) : false ;
224
+ }
225
+ else if ($ options && isset ($ options ['password-encoding ' ]) && $ options ['password-encoding ' ] === 'b ' ){
226
+ //extracting base64 encoded password
227
+ $ pass = isset ($ parts ['pass ' ]) ? base64_decode ($ parts ['pass ' ]) : false ;
228
+ }
229
+ else {
230
+ //extracting pass directly since 'password-encoding' parameter is not present
231
+ $ pass = isset ($ parts ['pass ' ]) ? $ parts ['pass ' ] : false ;
232
+ }
233
+
221
234
return array (
222
235
$ parts ['host ' ],
223
236
$ port ,
You can’t perform that action at this time.
0 commit comments