diff --git a/ElementX/Sources/Other/HTMLParsing/DTHTMLElement+AttributedStringBuilder.swift b/ElementX/Sources/Other/HTMLParsing/DTHTMLElement+AttributedStringBuilder.swift
index 483138e58..5c3635ee9 100644
--- a/ElementX/Sources/Other/HTMLParsing/DTHTMLElement+AttributedStringBuilder.swift
+++ b/ElementX/Sources/Other/HTMLParsing/DTHTMLElement+AttributedStringBuilder.swift
@@ -18,6 +18,16 @@ public extension DTHTMLElement {
// Remove any attachments to fix rendering.
textAttachment = nil
+ // Handle special case for span with data-mx-external-payment-details
+ // This could be based on Storefront.current.countryCode to show the link
+ // content in unrestricted countries. e.g. currently USA
+ if name == "span",
+ let attributes = attributes as? [String: String],
+ attributes["data-msc4286-external-payment-details"] != nil {
+ parent.removeChildNode(self)
+ return
+ }
+
// If the element has plain text content show that,
// otherwise prevent the tag from displaying.
if let stringContent = attributedString()?.string,
diff --git a/UnitTests/Sources/AttributedStringBuilderTests.swift b/UnitTests/Sources/AttributedStringBuilderTests.swift
index 1af255b28..1dd234853 100644
--- a/UnitTests/Sources/AttributedStringBuilderTests.swift
+++ b/UnitTests/Sources/AttributedStringBuilderTests.swift
@@ -1020,7 +1020,23 @@ class AttributedStringBuilderTests: XCTestCase {
XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org")
XCTAssertEqual(link.confirmationParameters?.displayString, "👉️ #room:matrix.org")
}
-
+
+ func testMxExternalPaymentDetailsRemoved() {
+ let htmlString = "This is visible. But text is hidden and this link too"
+
+ guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else {
+ XCTFail("Could not build the attributed string")
+ return
+ }
+
+ XCTAssertEqual(String(attributedString.characters), "This is visible")
+
+ for run in attributedString.runs where run.link != nil {
+ XCTFail("No link expected, but found one")
+ return
+ }
+ }
+
// MARK: - Private
private func checkLinkIn(attributedString: AttributedString?, expectedLink: String, expectedRuns: Int) {