[Bug][iOS] 正则消息过滤对 Rich Message(富文本帖)不生效:正文不在 message.text 中
还没有人认领这个 Issue。
评估
调研方向
Start by reading NagramRegexFilters.swift and the listed call sites in ChatHistoryEntriesForView.swift, ChatController.swift, ChatListNodeEntries.swift, NotificationService.swift, and NagramFilteredUnreadBadge.swift. Trace how RichTextMessageAttribute stores block text and how the filter currently handles empty message.text; then check existing regex filter tests. Done means Rich Message text is filtered consistently in chat, lists, notifications, and unread counts, with coverage for rich and ordinary messages.
由索引模型根据 Issue 内容生成。
描述
环境
- Nagram iOS(App Store 版)
- iPhone 15 Pro / iOS 27.3 beta 1
现象
同一频道、同一分钟内的四条机场广告帖,普通图文帖被正则过滤正确隐藏,
三条富文本帖(Rich Message)全部漏过。规则、开关均确认无误
(同一条正则对普通帖生效;把富文本内容拼成纯文本后离线测试也能命中)。
证据(MTProto 原始消息结构)
公开频道「破解软件资源分享」(channel_id 1538893263),2026-11-17:
- msg 11812(芒果云):普通 MessageMediaPhoto + caption,message 字段为
完整正文(570 字)→ 被正确隐藏 - msg 11809(Matcha)、11810(9527)、11813(星驰):未被隐藏。三者的
原始结构一致:message=""、media=null、entities=[]、reply_markup=null,
全部内容位于 rich_message.blocks 中(PageBlockPhoto /
PageBlockHeading2 / PageBlockBlockquoteBlocks / PageBlockParagraph,
文本由 TextPlain / TextBold / TextUrl / TextCustomEmoji 段组成)
根因(源码)
过滤的全部调用点只把 message.text 送入匹配:
- submodules/TelegramUI/Sources/ChatHistoryEntriesForView.swift:192
nagramRegexFilterMatcher.apply(to: message.text, ...) - submodules/TelegramUI/Sources/ChatController.swift:7754
matcher.isHidden(text: message.text, ...) - ChatListNodeEntries.swift:652、707,NotificationService.swift:2287,
NagramFilteredUnreadBadge.swift:170 同理
Rich Message 的正文存放在 RichTextMessageAttribute 中,Message.text
为空;而 NagramRegexFilters.swift 的 applyUncached 对空文本直接跳过
(guard !currentText.isEmpty),因此这类消息永远不可能命中任何规则。
建议修复
构造待匹配文本时:若 message.text 为空且消息带有
RichTextMessageAttribute,按 blocks 顺序提取其纯文本参与匹配
(或与 message.text 合并后匹配)。聊天内展示、会话列表、通知、
未读计数四处调用点应一致处理。
影响
富文本帖正被频道广告大量采用(排版更好,且恰好完全绕过文本过滤),
随着采用率上升,正则过滤对频道广告将整体失效。
- 主要语言
- Swift
- 星标
- 151
- 派生
- 22
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NextAlone/Nagram-iOS 的其他 Issue
-
置顶消息会显示已屏蔽消息问题未关闭bug
难度 3/5 1-2 天 新手友好度 58/100
NextAlone/Nagram-iOS#77 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
NextAlone/Nagram-iOS#71 · 1 个 reaction ·
-
频道内容的评论区加载异常未关闭bug
难度 3/5 1-2 天 新手友好度 48/100
NextAlone/Nagram-iOS#69 ·
-
难度 4/5 3-5 天 新手友好度 45/100
NextAlone/Nagram-iOS#65 · 1 条评论 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 35/100
NextAlone/Nagram-iOS#63 ·
查看 NextAlone/Nagram-iOS 的全部 Issue
相似的 Issue
-
[cloud_functions]: Apple platforms ignore custom domains passed as region可能已有人在做 @ragavendranbala-TSL 今天认领。 未关闭Needs Attention platform: ios platform: macos plugin: functions type: bug
难度 2/5 1-3 小时 新手友好度 78/100
firebase/flutterfire#19015 · 2 条评论 ·
维护者通常 4 天内回复
-
难度 1/5 1 小时以内 新手友好度 77/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 66/100
ecdye/macSubtitleOCR#98 ·
-
P3
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
macos-15
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复