Repository navigation
Conversation
parseUserID checked strings.Contains(q, "user:me"), so a search for "user:melissa" (or any username that starts with "me") was treated as "user:me": it filtered by the searcher's own ID, or by no one for a visitor, and left "lissa" behind as a search word. Treat the query as "user:me" only when the username in the user: token is exactly "me".
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.
Fixes #1665
Proposed Changes
parseUserID, treat the query asuser:meonly when the username in theuser:token is exactlyme, instead of whenever the query contains the textuser:me.search_parser_test.gowith cases foruser:meand for a username that starts withme, with and without an extra search word.Searching
user:melissa(or any username that starts withme) was handled asuser:me. A visitor got results from every author, a signed-in user got only their own posts, andlissawas left over as a search word. The parse happens before the search plugin is called, so plugins got the same wrong condition.I ran Answer from
dev(ec5e0e9) in Docker with SQLite and searched throughGET /answer/api/v1/searchwith two users, melissa and bob, one question each. Before the change,user:melissareturned 0 results anduser:melissa serviceas a visitor returned 2 (melissa's and bob's question). With the change both return melissa's question only.user:bob,user:meanduser:me servicereturn the same results as before.TestParseStructureUserfails ondevfor the twouser:melissacases (expected: "2",actual: "1", the searcher's own ID) and passes with the change.go test ./internal/service/... ./internal/schema/...,go vetandgolangci-lint run(v2.6.2) pass, andgo mod tidyleavesgo.modunchanged. I did not run the ASF header check (hawkeye) or test with a search plugin installed.