Skip to content

[ticket/17614] Remove invalid syntax from sphinx search queries#6987

Open
ECYaz wants to merge 1 commit into
phpbb:3.3.xfrom
ECYaz:ticket/17614
Open

[ticket/17614] Remove invalid syntax from sphinx search queries#6987
ECYaz wants to merge 1 commit into
phpbb:3.3.xfrom
ECYaz:ticket/17614

Conversation

@ECYaz

@ECYaz ECYaz commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Checklist:

  • Correct branch: 3.3.x for fixes
  • Tests pass
  • Code follows coding guidelines
  • Commit follows commit message format

Tracker ticket:

https://tracker.phpbb.com/browse/PHPBB-17614

A search containing an unmatched parenthesis or quotation mark, for example search.php?keywords=test+%29, makes searchd reject the whole query with a syntax error. The user gets a general error and a critical LOG_SPHINX_ERROR entry is logged. Empty groups like () and operators without an operand fail the same way.

This cleans the query at the end of sphinx_clean_search_string(): unmatched quotation marks and parentheses, empty groups and operators without an operand are removed. Valid syntax such as (either | or), nested groups and phrases is preserved. If nothing searchable remains after cleaning, the search returns no results instead of sending an empty query that would match every post.

@github-actions

Copy link
Copy Markdown

The attempt to merge branch 3.3.x into master has completed after considering the changes in this PR.

  • Merge result: Conflict ❌

A separate PR will be needed to merge 3.3.x into master.

Unmatched parentheses or quotation marks in the keywords, as well as
parenthesized groups and operators left without any search term, made
searchd fail the whole query with a syntax error which was logged and
shown to the user as a general error.

Clean the query in sphinx_clean_search_string() by removing unmatched
quotation marks and parentheses (ignoring those within quotation marks),
term-less groups and operators without an operand, while keeping valid
grouping syntax like (either | or) intact. Skip querying altogether if
no searchable term is left after cleaning.

PHPBB-17614
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant