Support usernames containing brackets (#3365)

* wrapped $user in preg_quote function
* updated auth test for special character in username

Co-authored-by: Léo Colombaro <git@colombaro.fr>
Co-authored-by: ྅༻ Ǭɀħ ༄༆ཉ <ozh@ozh.org>
This commit is contained in:
SXN31 2023-02-11 08:26:37 -08:00 committed by GitHub
parent 2efcb9e93a
commit f2971a1a35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -213,7 +213,7 @@ function yourls_hash_passwords_now( $config_file ) {
// PHP would interpret $ as a variable, so replace it in storage.
$hash = str_replace( '$', '!', $hash );
$quotes = "'" . '"';
$pattern = "/[$quotes]{$user}[$quotes]\s*=>\s*[$quotes]" . preg_quote( $password, '/' ) . "[$quotes]/";
$pattern = "/[$quotes]" . preg_quote( $user, '/' ) . "[$quotes]\s*=>\s*[$quotes]" . preg_quote( $password, '/' ) . "[$quotes]/";
$replace = "'$user' => 'phpass:$hash' /* Password encrypted by YOURLS */ ";
$count = 0;
$configdata = preg_replace( $pattern, $replace, $configdata, -1, $count );

View File

@ -8,5 +8,6 @@ $yourls_user_passwords = array(
'quote1' => '"ahah"',
'quote2' => "'ahah'",
'utf8fun' => 'أنا أحب النقانق',
's[p]e(c)i{a}!@#$%^&*-=l<>,/?' => 'password',
);