Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SynonymAnalyzer.php in module-search is evaluating user input as a regex #25886

Closed
dan-ding opened this issue Dec 3, 2019 · 6 comments · Fixed by #30318
Closed

SynonymAnalyzer.php in module-search is evaluating user input as a regex #25886

dan-ding opened this issue Dec 3, 2019 · 6 comments · Fixed by #30318
Assignees
Labels
Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@dan-ding
Copy link

dan-ding commented Dec 3, 2019

Preconditions (*)

2.3.2-xyz
2.3-develop
prolly others

Steps to reproduce (*)

  1. install magento
  2. enable elasticsearch
  3. do a weird search for something like: http://www.a
    GET /catalogsearch/result/?q=http://www.a

Expected result (*)

  1. the search results screen saying the term couldn't be found

Actual result (*)

  1. error message
  2. in production mode, error report is generated

The error that occurs is on line 96 of search/Model/SynonymAnalyzer.php:

$matchingResultCode = preg_match($pattern, $synonymGroup);

the error message:
report.ERROR: Warning: preg_match(): Unknown modifier '/' in /var/www/html/vendor/magento/module-search/Model/SynonymAnalyzer.php on line 96

preg_match is evaluating the user input as a regex

@m2-assistant
Copy link

m2-assistant bot commented Dec 3, 2019

Hi @dan-ding. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@dan-ding do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 3, 2019
@dan-ding
Copy link
Author

dan-ding commented Dec 3, 2019

@magento this can't be shown on an instance as it requires elasticsearch

@engcom-Charlie engcom-Charlie self-assigned this Dec 4, 2019
@m2-assistant
Copy link

m2-assistant bot commented Dec 4, 2019

Hi @engcom-Charlie. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Charlie
Copy link
Contributor

Hello @dan-ding
We are not able to reproduce this issue on the latest 2.3-develop branch by provided steps.

Manual testing scenario:

  1. istall magento
  2. enable elasticsearch
  3. do a weird search for something like: http://www.a
  4. GET /catalogsearch/result/?q=http://www.a

Result:
The search results screen saying the term couldn't be found
Browser:
image
Postman:
image

So i have to close this issue.
Thank you for contribution and collaboration!

@wojtekn
Copy link
Contributor

wojtekn commented Oct 2, 2020

@magento-engcom-team this was closed because it wasn't reproduced. However, incorrect steps were used so this should be reopened.

The problem can be reproduced only when synonym exists for given phrase. So to reproduce:

  1. Ensure the synonym exists in SEO & Search -> Search Synonyms:
    foo,bar"foobar",
  2. With ES enabled as search backend, search for "Foo/Bar" in frontend.

Expected behavior would be search results page, either empty or one showing results.

Current behavior is the exception:

1 exception(s):
Exception #0 (Exception): Warning: preg_match(): Unknown modifier 'B' in /var/www/html/vendor/magento/module-search/Model/SynonymAnalyzer.php on line 96

@magento-engcom-team
Copy link
Contributor

Hi @dan-ding. Thank you for your report.
The issue has been fixed in #30318 by @wojtekn in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.2 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants