[Bug][iOS] 正则消息过滤对 Rich Message(富文本帖)不生效:正文不在 message.text 中
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
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.
Written by the indexing model from the issue text.
Description
环境
- 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 合并后匹配)。聊天内展示、会话列表、通知、
未读计数四处调用点应一致处理。
影响
富文本帖正被频道广告大量采用(排版更好,且恰好完全绕过文本过滤),
随着采用率上升,正则过滤对频道广告将整体失效。
- Dominant language
- Swift
- Stars
- 151
- Forks
- 22
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NextAlone/Nagram-iOS
-
置顶消息会显示已屏蔽消息问题Openbug
Difficulty 3/5 1-2 days Newbie friendliness 58/100
NextAlone/Nagram-iOS#77 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
NextAlone/Nagram-iOS#71 · 1 reaction ·
-
频道内容的评论区加载异常Openbug
Difficulty 3/5 1-2 days Newbie friendliness 48/100
NextAlone/Nagram-iOS#69 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
NextAlone/Nagram-iOS#65 · 1 comment · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
NextAlone/Nagram-iOS#63 ·
All issues in NextAlone/Nagram-iOS
Similar issues
-
[cloud_functions]: Apple platforms ignore custom domains passed as regionPossibly taken @ragavendranbala-TSL claimed this today. OpenNeeds Attention platform: ios platform: macos plugin: functions type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
firebase/flutterfire#19015 · 2 comments ·
Maintainers usually reply within 4 days
-
Difficulty 1/5 Under an hour Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
ecdye/macSubtitleOCR#98 ·
-
P3
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
macos-15
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
thaw-app/Thaw#1708 · 1 comment ·
Maintainers usually reply within 1 day