Skip to content

Fix issue #749: Handle special characters in search queries safely#761

Open
pr0vieh wants to merge 1 commit intoyacy:masterfrom
pr0vieh:fix/issue-749-search-special-chars
Open

Fix issue #749: Handle special characters in search queries safely#761
pr0vieh wants to merge 1 commit intoyacy:masterfrom
pr0vieh:fix/issue-749-search-special-chars

Conversation

@pr0vieh
Copy link
Contributor

@pr0vieh pr0vieh commented Jan 28, 2026

The parseQuery method had a bug that caused StringIndexOutOfBoundsException when searching for queries containing special characters like '&<--'.

The issue occurred due to:

  1. Improper index tracking in substring extraction
  2. Unsafe string boundary checks
  3. Unconditional index increment that could go out of bounds

This fix:

  • Safely extracts tokens by checking boundaries (p > 0 and p > 1)
  • Differentiates between quoted and unquoted strings properly
  • Trims and validates extracted strings
  • Uses continue to skip empty tokens
  • Prevents StringIndexOutOfBoundsException

got it from #749 (comment) thx @smokingwheels
Fixes #749

The parseQuery method had a bug that caused StringIndexOutOfBoundsException
when searching for queries containing special characters like '&<--'.

The issue occurred due to:
1. Improper index tracking in substring extraction
2. Unsafe string boundary checks
3. Unconditional index increment that could go out of bounds

This fix:
- Safely extracts tokens by checking boundaries (p > 0 and p > 1)
- Differentiates between quoted and unquoted strings properly
- Trims and validates extracted strings
- Uses continue to skip empty tokens
- Prevents StringIndexOutOfBoundsException

thx smokingwheels
Fixes yacy#749
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.

unable to search &<--

1 participant

Comments