Repository navigation
fix(files): Escape search path filter and match the folder only - #67683
Open
kukanggg89 wants to merge 1 commit into
Open
kukanggg89 wants to merge 1 commit into
kukanggg89 wants to merge 1 commit into
Conversation
The path filter built its LIKE pattern from the raw folder name, so searching in /Photos also matched /Photos 2023 and /Photos-backup, and _ and % in a folder name acted as wildcards. Escape the folder name with SearchComparison::escapeLikeParameter() and require a trailing slash, so the pattern only matches the folder and its children. The root folder is handled separately with a plain files/% pattern. Adds unit tests for the built LIKE pattern covering a plain folder, leading and trailing slashes, the root folder, and folder names containing _, % and backslash. Fixes nextcloud#67440 Signed-off-by: parel <farelalfarizi89@gmail.com> Assisted-by: Muse:Muse Spark 1.3
kukanggg89
requested review from
GhassenKefi and
vlotysh
and removed request for
a team
December 4, 2026 07:34
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Searching "in folder"
/Photosalso returned files from/Photos 2023and/Photos-backup, because the path filter built its LIKE pattern from the raw folder name with no trailing slash. A_or%in a folder name acted as a wildcard too.FilesSearchProvider::buildSearchQuery()now builds the path comparison through a newbuildPathSearchQuery()helper, which escapes the folder name withSearchComparison::escapeLikeParameter()and requires a trailing slash, so the pattern only matches the folder and its children. Searching the root folder is handled separately with a plainfiles/%pattern. This is the same shapeCacheJailalready uses.apps/files/tests/Search/FilesSearchProviderTest.phpgets a data-provider test asserting the built LIKE pattern for a plain folder, leading and trailing slashes, the root folder, and folder names containing_,%, and a backslash.The
termfilter is left alone. The issue notes it is unescaped too but possibly intended as a plain substring search, so that is out of scope here.Verification: the new tests were not run locally, there is no PHP on the machine this change was made on, so CI has to run them. The LIKE patterns were checked by simulating old versus new patterns against folder paths: the new pattern matches the folder and its children only, while the old one also matched sibling folders and treated
_and%as wildcards.TODO
No open TODOs.
Checklist
3. to review, feature component) (n/a: maintainers set labels)stable32) (n/a: maintainers set the milestone)AI (if applicable)
Drafted with help from Claude. I reviewed and revised every change myself before opening this PR.