镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../message_media.dart';
import 'markdown_escapes.dart';

/// Splits top-level media from text without breaking Markdown blocks.
/// Fenced code, lists and quotes retain their nested content.
Expand Down Expand Up @@ -44,7 +45,9 @@ List<({String text, bool attachment})> messageBubbleSegments(
: embed.firstMatch(line.trimRight());
final isAttachment =
match != null &&
(line.trim().startsWith('!') || imeta.containsKey(match.group(1)));
(line.trim().startsWith('!') ||
// Content arrives with escapes shielded; imeta keys are plain.
imeta.containsKey(unshieldMarkdownEscapes(match.group(1)!)));
if (attachment != null &&
isAttachment != attachment &&
line.trim().isNotEmpty) {
Expand Down
3 changes: 2 additions & 1 deletion mobile/lib/features/channels/message_gallery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ TrailingImageGallery? extractTrailingImageGallery(
while (cursor >= 0) {
final match = imagePattern.firstMatch(lines[cursor].trim());
if (match == null) break;
final url = match.group(2)!;
// CommonMark unescapes link destinations, as it does labels below.
final url = unshieldMarkdownEscapes(shieldMarkdownEscapes(match.group(2)!));
final imeta = imetaByUrl[url];
final mediaKind = classifyMediaUrl(url, imeta: imeta);
if (mediaKind != MessageMediaKind.image) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,10 @@ void bubbleContentTests() {
_testable(
const MessageContent(
content:
'Before\n\n[file.txt](https://example.com/file.txt)\n\nAfter',
// The escaped destination must still match its plain imeta URL.
'Before\n\n[file.txt](https://example.com/file\\_a.txt)\n\nAfter',
tags: [
['imeta', 'url https://example.com/file.txt', 'm text/plain'],
['imeta', 'url https://example.com/file_a.txt', 'm text/plain'],
],
bubble: true,
),
Expand Down
5 changes: 3 additions & 2 deletions mobile/test/features/channels/message_content_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,8 @@ void main() {
'groups uploaded photos into a carousel and opens the full gallery',
(tester) async {
const first = 'https://example.com/media/one.png';
const second = 'https://example.com/media/two.png';
// The second destination is escaped; the carousel must unescape it.
const second = 'https://example.com/media/two_2.png';
const third = 'https://example.com/media/three.png';
await tester.pumpWidget(
_testable(
Expand All @@ -1933,7 +1934,7 @@ void main() {
'''
Photos
![image]($first)
![image]($second)
![image](https://example.com/media/two\\_2.png)
![image]($third)
''',
tags: [
Expand Down
Loading