Skip to content

Problem with escapeTerm and lowercase operator #1155

@marmol

Description

@marmol

Solarium version(s) affected: 6.3.*
Solr version: all
Solr mode: standalone / cloud

Description
A term containing words and,or,to in lowercase are considered as AND OR TO solr operator.
Why is there a strtoupper before preg_match.
The term must contain upper AND OR TO, lower is not a problem!

Core/Query/Helper.php

public function escapeTerm(string $input): string
    {
        if (preg_match('/(^|\s)(AND|OR|TO)($|\s)/', strtoupper($input), $matches)) {
            return $this->escapePhrase($input);
        }

        return preg_replace('/( |\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\/|\\\)/', '\\\$1', $input);
    }

How to reproduce
Use a term with "foo and bar"

Possible Solution
Suppress strtoupper in preg_match call.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions