LengthValidator should use mb_strlen instead of strlen

Open Beginner friendly
#917 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
php
Domain
security

Research direction

Open lib/Validator/LengthValidator.php at the linked line and inspect how password length is calculated. Verify the behavior against the issue's ASCII and Chinese examples, then confirm that multibyte characters are counted as intended.

Written by the indexing model from the issue text.

Description

0. Needs triage bug
How to use GitHub
  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Code:

https://github.com/nextcloud/password_policy/blob/04ed1480044aeadf0f4be5b78868ff57b8f0e063/lib/Validator/LengthValidator.php#L26

Sample:

<?php

$a = '12345';
$b = '密码密码';

var_dump(
    strlen($a),
    strlen($b),
    mb_strlen($a), 
    mb_strlen($b),
);

Output:

int(5)
int(12)
int(5)
int(4)
Dominant language
PHP
Stars
39
Forks
27
Avg merge
1h 36m
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextcloud/password_policy

All issues in nextcloud/password_policy

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.