Skip to content

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

Closed
@dan-ding

Description

@dan-ding

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

Metadata

Metadata

Labels

Fixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Format is validGate 1 Passed. Automatic verification of issue format passed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions