Bug Fix: slugifyLikeString skips sanitization due to unassigned replace() result

未关闭 适合新手
#6,782 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

@deepak0x 已经在做这个了。

开始于 2025年11月10日。

  • #6784 来自 @deepak0x —— 未关闭

评估

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

调研方向

从 app/lib/database/utils.ts 中的 slugifyLikeString 开始,并检查 app/lib/methods/search.ts 和 app/lib/methods/helpers/mergeSubscriptionsRooms.ts 中对它的调用方。确认被忽略的 replace() 结果如何影响 slug 化,然后验证在 slugify() 接收该值之前特殊字符已被清理,并且受影响的调用点仍按预期运行。

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

描述

🐛 bug
Describe the Bug

The function slugifyLikeString in app/lib/database/utils.ts (around line 14) contains a bug where the replace() result is not assigned or returned.
Because of this, the string sanitization step is effectively skipped, and the unsanitized string (which may contain special characters) is passed directly to slugify().

Steps to Reproduce

Open app/lib/database/utils.ts.

Locate the slugifyLikeString function (lines 12–17).

Notice this line:

str?.replace(likeStringRegex, '_');

The result of replace() is not assigned back to str or returned.

This means the sanitization step does not take effect before the string is passed to slugify().

Expected Behavior

The line should assign the result of replace() back to the variable:

str = str?.replace(likeStringRegex, '_') ?? str;

OR
chain the operation like this:

const sanitized = str.replace(likeStringRegex, '_');
const slugified = slugify(sanitized);
return slugified;

The string should always be sanitized before being passed to slugify().

Actual Behavior

The replace() on line 14 does nothing because its result is ignored.

The raw string with special characters is passed directly to slugify().

The sanitization step is effectively skipped.

Rocket.Chat Server Version

N/A (Code bug fix)

Rocket.Chat App Version

4.67.0

Device Name

N/A

OS Version

N/A

Additional Context

File: app/lib/database/utils.ts

Impact: The slugifyLikeString function is used in:

  • app/lib/methods/search.ts
  • app/lib/methods/helpers/mergeSubscriptionsRooms.ts

Note: This bug means special characters may not be properly sanitized before slugification, which could lead to unexpected behavior in search and room merging functionality.

主要语言
TypeScript
星标
2.4k
派生
1.5k
平均合并
5 天 16 小时
30 天内合并 PR
38

环境准备

从这里开始

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

RocketChat/Rocket.Chat.ReactNative 的其他 Issue

查看 RocketChat/Rocket.Chat.ReactNative 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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