magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Customer name validation is failed if name contains only special characters

Open KaushikChavda opened this issue 2 years ago • 16 comments

Preconditions and environment

  • Magento version Adobe Commerce ver. 2.4.5-p5

  • Suppose you have various old customer which was created in 2020 and only contains special characters

  • then name validator \Magento\Customer\Model\Validator\Name::isValidName is failed

  • Method should be validated name like this. `private function isValidName($nameValue) { if ($nameValue != null) { if (preg_match(self::PATTERN_NAME, $nameValue, $matches)) { return $matches[0] == $nameValue; } else { return false; } }

      return true;
    

    }`

  • Anything else that would help a developer reproduce the bug

Steps to reproduce

  • Update any customer's first name and last name with special characters only
  • then open that customer from the backend Magento
  • and just shave that customer Magento

Expected result

we should get the errors like this,

  1. First Name is not valid!
  2. Middle Name is not valid!
  3. Last Name is not valid!

Actual result

its saved the customer with the special charactersIt

Additional information

No response

Release note

No response

Triage and priority

  • [X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [X] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [X] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [X] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

KaushikChavda avatar Nov 17 '23 11:11 KaushikChavda

Hi @KaushikChavda. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

m2-assistant[bot] avatar Nov 17 '23 11:11 m2-assistant[bot]

Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

m2-assistant[bot] avatar Nov 28 '23 01:11 m2-assistant[bot]

Hi @KaushikChavda

Thanks for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible. We are not getting errors messages and able to save the changes successfully when the first ,middle and last name of the customer contains only special characters.Kindly refer the screenshots.

We are considering this as improvisation hence marking this as feature request to proceed further SpecialCharacters

Specialcharaters2

engcom-Dash avatar Nov 28 '23 14:11 engcom-Dash

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10607 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Nov 28 '23 14:11 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-Dash. Thank you for verifying the issue.
Issue Available: @engcom-Dash, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Nov 28 '23 14:11 m2-assistant[bot]

@magento I am working on this

aiqbalm avatar Mar 04 '24 05:03 aiqbalm

Hi @aiqbalm! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

m2-assistant[bot] avatar Mar 04 '24 05:03 m2-assistant[bot]

@magento add to contributors team

harihhs avatar Mar 04 '24 05:03 harihhs

Hi @harihhs! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

m2-assistant[bot] avatar Mar 04 '24 05:03 m2-assistant[bot]

@magento add to contributors team

aiqbalm avatar Mar 04 '24 05:03 aiqbalm

Hi @aiqbalm! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

m2-assistant[bot] avatar Mar 04 '24 05:03 m2-assistant[bot]

@magento I am working on this

aiqbalm avatar Mar 04 '24 05:03 aiqbalm

any updates? we meet this error when old customer placing order. and we upgrade from v2.3.1 to v2.4.6. please advise, how to solve this problem? thanks

lily-PHP avatar Apr 12 '24 03:04 lily-PHP

any updates? we meet this error when old customer placing order. and we upgrade from v2.3.1 to v2.4.6. please advise, how to solve this problem? thanks

Did you ever fix this? I'm stuck with the same problem right now

FedeltaMedia avatar Jul 22 '24 15:07 FedeltaMedia

We got today a similar problem where someone try an attack and tried to use the weak validation.

Screenshot 2024-08-27 at 08 51 40

I would agree to change the validation function as @KaushikChavda written.

    if ($nameValue != null) {		
        if (preg_match(PATTERN_NAME, $nameValue, $matches)) {
            return $matches[0] == $nameValue;
        } else {
        	return false;
        }
    }

boehsermoe avatar Aug 27 '24 06:08 boehsermoe

any updates? we meet this error when old customer placing order. and we upgrade from v2.3.1 to v2.4.6. please advise, how to solve this problem? thanks

Did you ever fix this? I'm stuck with the same problem right now

I made a php code to foreach all the data from table customer_entity, to check all customers' first name and last name field whether match the regexp or not. the regexp is from file /vendor/magento/module-customer/Model/Validator/Name.php the private const PATTERN_NAME = '/(?:[\p{L}\p{M},-_.'’`\s\d]){1,255}+/u'; if not match the regexp, then correct the customer's name data. This method is not smart, but can solve our old customers data. :-)

lily-PHP avatar Aug 29 '24 11:08 lily-PHP