diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 0eea5a85d..7a6a47bc8 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -216,6 +216,14 @@ class AddressResolver { return emailRegex.hasMatch(address); } + String _stripHtmlTags(String value) { + return value + .replaceAll(RegExp(r'', caseSensitive: false), '\n') + .replaceAll(RegExp(r'', caseSensitive: false), '\n') + .replaceAll(RegExp(r'<[^>]*>'), '') + .trim(); + } + Future resolve(BuildContext context, String text, CryptoCurrency currency) async { final ticker = currency.title; try { @@ -348,7 +356,8 @@ class AddressResolver { await MastodonAPI.lookupUserByUserName(userName: userName, apiHost: hostName); if (mastodonUser != null) { - String? addressFromBio = extractAddressByType(raw: mastodonUser.note, type: currency, requireSurroundingWhitespaces: true); + final mastodonNote = _stripHtmlTags(mastodonUser.note); + String? addressFromBio = extractAddressByType(raw: mastodonNote, type: currency, requireSurroundingWhitespaces: true); if (addressFromBio != null && addressFromBio.isNotEmpty) { return ParsedAddress.fetchMastodonAddress( @@ -361,7 +370,7 @@ class AddressResolver { await MastodonAPI.getPinnedPosts(userId: mastodonUser.id, apiHost: hostName); if (pinnedPosts.isNotEmpty) { - final userPinnedPostsText = pinnedPosts.map((item) => item.content).join('\n'); + final userPinnedPostsText = pinnedPosts.map((item) => _stripHtmlTags(item.content)).join('\n'); String? addressFromPinnedPost = extractAddressByType(raw: userPinnedPostsText, type: currency, requireSurroundingWhitespaces: true);