Skip to content

Auto encrypting password does not work if username contains a square bracket #3364

@SXN31

Description

@SXN31

Code of Conduct

Submission validity

  • This is not a personal support request, that should be posted on discussions community.
  • I checked current issues and this request isn't a duplicate of an existing issue, opened or closed.

Self troubleshooting

Version

1.9.1

Description

If a user's name includes square brackets, the password will not be encrypted and a preg_replace error is reported.

Expectation

The password to be encrypted without any issue.

Reproduction steps

Add

$yourls_user_passwords = array(
    'testuser[2]' => 'password',
);

Context

Seems like the bracket might be breaking something for the preg_replace pattern.

$pattern = "/[$quotes]${user}[$quotes]\s*=>\s*[$quotes]" . preg_quote( $password, '/' ) . "[$quotes]/";

I only tried curly braces as an additional test, which did work, but even just 1 square bracket breaks the encryption.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions