fix(search): do not regex-escape the UID used for file lookups - #390
Open
mklemme1 wants to merge 1 commit into
Open
fix(search): do not regex-escape the UID used for file lookups#390mklemme1 wants to merge 1 commit into
mklemme1 wants to merge 1 commit into
Conversation
SearchService::improveSearchRequest() assigned the output of FilesService::secureUsername() -- a regex-escaping helper -- to $this->userId, which is then used as a real user ID. For any user whose UID contains a dot (michael.klemme@example.org becomes michael\.klemme@example.org), getFileFromId() threw NoUserException and improveSearchResult() silently dropped every file result, so the search returned empty. This only affected code paths without a user session, i.e. occ fulltextsearch:search. In the web UI $this->userId comes from IUserSession and is unescaped, so the same query worked there. Neither consumer of the field wants an escaped value: getFileFromId() needs a real UID, and substr($file->getPath(), 7 + strlen($this->userId)) needs the real length -- the escaped name is one character too long per dot, so the computed path would be truncated incorrectly even if the lookup succeeded. improveSearchRequest() is also reached after the constructor has already set the same field from the session as a plain UID, which is the field's contract. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes #389
SearchService::improveSearchRequest() assigned the output of FilesService::secureUsername() -- a regex-escaping helper -- to $this->userId, which is then used as a real user ID. For any user whose UID contains a dot (michael.klemme@example.org becomes michael.klemme@example.org), getFileFromId() threw NoUserException and improveSearchResult() silently dropped every file result, so the search returned empty.
This only affected code paths without a user session, i.e. occ fulltextsearch:search. In the web UI $this->userId comes from IUserSession and is unescaped, so the same query worked there.
Neither consumer of the field wants an escaped value: getFileFromId() needs a real UID, and substr($file->getPath(), 7 + strlen($this->userId)) needs the real length -- the escaped name is one character too long per dot, so the computed path would be truncated incorrectly even if the lookup succeeded. improveSearchRequest() is also reached after the constructor has already set the same field from the session as a plain UID, which is the field's contract.
馃 AI (if applicable)