Skip to content

Fix case sensitivity in search#3997

Merged
ozh merged 1 commit intomasterfrom
search-case
Oct 11, 2025
Merged

Fix case sensitivity in search#3997
ozh merged 1 commit intomasterfrom
search-case

Conversation

@ozh
Copy link
Copy Markdown
Member

@ozh ozh commented Oct 10, 2025

Stance : search should be CASE SENSITIVE regarding URLs and short URLs, but CASE INSENSITIVE regarding titles.

@ozh
Copy link
Copy Markdown
Member Author

ozh commented Oct 10, 2025

Testing with https://ozh.org/temp/UPLOL-lowrolf.html :

✔️ case sensitive for URL
image
image
image
image

✔️ case sensitive for short URL
image
image
image

✔️ case insensitive for titles
image
image
image
image

@dgw
Copy link
Copy Markdown
Member

dgw commented Oct 10, 2025

I tweaked #3997 (comment) a bit so it accurately describes the behavior of titles. :)

Is it overkill to use COLLATE now that you replaced CONCAT_WS() with multiple `field` LIKE (:search) clauses? If tested individually, I would think that each column would naturally behave according to its set collation. For title + ip, that's already utf8mb4_unicode_ci, and utf8mb4_bin for url + keyword.

If we can accomplish the same thing with fewer conditionals, it's nicer—and probably more performant if we can avoid making the DB convert collations. (Not that I expect search to be a major performance issue, but… why make things slow just because? 😁)

@ozh
Copy link
Copy Markdown
Member Author

ozh commented Oct 10, 2025

With no COLLATE clause, it doesn't work :

        $where['sql'] .= " AND `keyword` LIKE (:search)
                        OR `url` LIKE (:search)
                        OR `title` LIKE (:search)
                        OR `ip` LIKE (:search) ";
image

@dgw
Copy link
Copy Markdown
Member

dgw commented Oct 10, 2025

Ah, fun. Guess we'll do it this way, indeed.

@LeoColomb LeoColomb changed the title Fix case sensitivity in YOURLS search Fix case sensitivity in search Oct 11, 2025
@ozh ozh merged commit 43d39ad into master Oct 11, 2025
10 checks passed
@ozh ozh deleted the search-case branch October 11, 2025 14:53
tomtenuta pushed a commit to tomtenuta/YOURLS that referenced this pull request Nov 4, 2025
search now CASE SENSITIVE regarding URLs and short URLs, but CASE INSENSITIVE regarding titles
Fixes YOURLS#3996
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.

3 participants