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

Search function and non-english characters case sensitivity issue #5780

Closed
alexpi opened this issue Oct 11, 2023 · 2 comments · Fixed by #5829
Closed

Search function and non-english characters case sensitivity issue #5780

alexpi opened this issue Oct 11, 2023 · 2 comments · Fixed by #5829
Assignees
Milestone

Comments

@alexpi
Copy link

alexpi commented Oct 11, 2023

Description

When performing a site search using non-english characters, the search is performed with case sensitivity, so for example in Greek, searching for the word 'Βάρος', does not match 'βάρος' (Same word with a lowercase first letter).

Expected behavior

Your setup

Kirby Version

3.9.6.1

Your system (please complete the following information)

  • Device: Desktop PC
  • OS: Windows 10
  • Browser: Chrome, All
  • Version: 117

Additional context

I wrote about this issue in the forum, and @rasteiner explained the issue to me. I am quoting his answer (I hope that's ok):

"Kirby relies on the PCRE2 regex engine of PHP to find matches, it passes the i flag to the regex to make the search case insensitive, but in PCRE2 world, i only works for the ranges [a-zA-Z] (that’s only the 52 symbols of the English alphabet, like: it also [doesn’t match ü with Ü]. I guess Kirby could change that regular expression to [also include the u (Unicode) flag], that would fix the upper / lower case issue."

Is it possible that a small change to Kirby's code could fix this termporarily?

@rasteiner
Copy link
Contributor

rasteiner commented Oct 11, 2023

If you want to test it, change this line to

$preg    = '!(' . implode('|', $words) . ')!iu';

(just add a u after the i)

It should make a difference:
https://onlinephp.io?s=s7EvyCjg5eLlSk3OyFdQD88sycgvLVEotVJQ11MoKEpNj89NLEnO0FCvOTfp3Jrzjef2n2-qyVTXUVBQP7cJJqCuqaCnoBSTp2QNM0dBQQFkFCFzSoEGYTUHAA%2C%2C&v=8.2.7%2C8.1.20%2C8.0.29

@alexpi
Copy link
Author

alexpi commented Oct 11, 2023

Yes it works!

@distantnative distantnative self-assigned this Oct 19, 2023
@distantnative distantnative added this to the 3.9.8 milestone Oct 19, 2023
distantnative added a commit that referenced this issue Oct 19, 2023
distantnative added a commit that referenced this issue Oct 19, 2023
@distantnative distantnative linked a pull request Oct 19, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

5 participants