File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 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)
207207 $ database = intval (preg_replace ('/[^0-9]/ ' , '' , $ parts ['path ' ]));
208208 }
209209
210- // Extract any 'user' and 'pass' values
210+ // Extract any 'user' values
211211 $ user = isset ($ parts ['user ' ]) ? $ parts ['user ' ] : false ;
212- $ pass = isset ($ parts ['pass ' ]) ? $ parts ['pass ' ] : false ;
213212
214213 // Convert the query string into an associative array
215214 $ options = array ();
@@ -218,6 +217,20 @@ public static function parseDsn($dsn)
218217 parse_str ($ parts ['query ' ], $ options );
219218 }
220219
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+
221234 return array (
222235 $ parts ['host ' ],
223236 $ port ,
You can’t perform that action at this time.
0 commit comments