Searching user:<username> returns the wrong posts when the username starts with "me"

未关闭
#1,665 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 6 天内回复

还没有人认领这个 Issue。

  • #1667 来自 @granbellllc-png —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
search

调研方向

The issue identifies the search parser’s strings.Contains(q, "user:me") check and says the bug occurs before search plugins run; it does not name the parser file or an existing test. Start by locating that check and the search parser tests, then verify that user:me still means the current user while user:melissa returns only melissa’s posts. The author says they have a fix and plan to open a pull request, so check for that work before starting.

由索引模型根据 Issue 内容生成。

描述

Describe the bug

The search tips say user:username searches by author. For any username that starts with me (melissa, megan, meng, mei, ...) the search is treated as user:me instead. A visitor gets results from every author, a signed-in user gets only their own posts, and the rest of the username (lissa) is searched as a word.

The search parser checks strings.Contains(q, "user:me") before it looks up the username, so user:melissa matches that check. This happens before the search plugin is called, so it affects the built-in search and the search plugins alike.

To Reproduce

  1. Create two users, melissa and bob.
  2. As melissa, ask "Which port does the parking service use". As bob, ask "Where is the store service configuration".
  3. Search user:bob: one result, bob's question.
  4. Search user:melissa: no results.
  5. Search user:melissa service while signed out: two results, melissa's and bob's question.

I ran this against dev at ec5e0e9 (SQLite, installed with the AUTO_INSTALL environment variables), calling GET /answer/api/v1/search?order=newest the way the search box does:

q='user:bob' as anonymous               count 1  authors [bob]
q='user:melissa' as anonymous           count 0  authors []
q='user:melissa' as admin               count 0  authors []
q='user:melissa service' as anonymous   count 2  authors [melissa, bob]
q='user:me' as melissa                  count 1  authors [melissa]

Expected behavior

user:melissa returns melissa's posts, the same way user:bob returns bob's. Only user:me itself should mean the current user.

Screenshots

None, the output above is from the API.

Platform

  • Device: Desktop (API calls with curl)
  • OS: Linux (Docker, golang:1.25)
  • Browser and version: not used
  • Version: dev at ec5e0e9; the same check is on main

I have a fix with a test and will open a pull request for it.

主要语言
Go
星标
15.7k
派生
1.4k
平均合并
9 天 6 小时
30 天内合并 PR
8

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/answer 的其他 Issue

查看 apache/answer 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。