From e0eb1a993a4a6f680e6617e818cb0706122d046a Mon Sep 17 00:00:00 2001 From: Guille Gonzalez Date: Fri, 22 Jul 2022 18:15:28 +0200 Subject: [PATCH] Fix hang when trying to load invalid image (#113) --- .../Rendering/NSAttributedString+ImageLoading.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/MarkdownUI/Rendering/NSAttributedString+ImageLoading.swift b/Sources/MarkdownUI/Rendering/NSAttributedString+ImageLoading.swift index 539641f1..077e058c 100644 --- a/Sources/MarkdownUI/Rendering/NSAttributedString+ImageLoading.swift +++ b/Sources/MarkdownUI/Rendering/NSAttributedString+ImageLoading.swift @@ -31,6 +31,10 @@ extension NSAttributedString { } } + guard !imageAttachmentPublishers.isEmpty else { + return Just(attributedString).eraseToAnyPublisher() + } + return Publishers.MergeMany(imageAttachmentPublishers) .collect() .map { Dictionary($0, uniquingKeysWith: { _, last in last }) }