Cleaner removePassword regex

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
pull/26346/head
J0WI 2021-03-27 18:41:43 +07:00
parent aec9c8437a
commit 5f468c0248
2 changed files with 8 additions and 4 deletions

@ -39,7 +39,7 @@ class ErrorHandler {
* @return string
*/
protected static function removePassword($msg) {
return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg);
return preg_replace('#//(.*):(.*)@#', '//xxx:xxx@', $msg);
}
public static function register($debug = false) {

@ -30,11 +30,15 @@ class ErrorHandlerTest extends \Test\TestCase {
*/
public function passwordProvider() {
return [
['user', 'password'],
['user@owncloud.org', 'password'],
['user', 'pass@word'],
['us:er', 'pass@word'],
['us:er', 'password'],
['user', '-C:R,w)@6*}'],
['user', 'pass:word'],
['user', 'pass@word'],
['user', 'password'],
['user:test@cloud', 'password'],
['user@owncloud.org', 'password'],
['user@test@owncloud.org', 'password'],
];
}