From bdd1876a1d41605c2288228ae926c6773fb51b45 Mon Sep 17 00:00:00 2001 From: szydlovsky <9szydlowski9@gmail.com> Date: Tue, 18 Nov 2025 11:49:36 +0100 Subject: [PATCH 1/2] feat: make tags with no href or empty href not treated as links --- ios/inputParser/InputParser.mm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ios/inputParser/InputParser.mm b/ios/inputParser/InputParser.mm index d0d2002e2..01a85a3d4 100644 --- a/ios/inputParser/InputParser.mm +++ b/ios/inputParser/InputParser.mm @@ -610,9 +610,20 @@ - (NSArray *)getTextAndStylesFromHtml:(NSString *)fixedHtml { } else if([tagName isEqualToString:@"code"]) { [styleArr addObject:@([InlineCodeStyle getStyleType])]; } else if([tagName isEqualToString:@"a"]) { + NSRegularExpression *hrefRegex = [NSRegularExpression regularExpressionWithPattern:@"href=\".+\"" + options:0 + error:nullptr + ]; + NSTextCheckingResult* match = [hrefRegex firstMatchInString:params options:0 range: NSMakeRange(0, params.length)]; + + if(match == nullptr) { + // same as on Android, no href (or empty href) equals no link style + continue; + } + + NSRange hrefRange = match.range; [styleArr addObject:@([LinkStyle getStyleType])]; - // cut only the url from the href="..." string - NSString *url = [params substringWithRange:NSMakeRange(6, params.length - 7)]; + NSString *url = [params substringWithRange:NSMakeRange(hrefRange.location + 6, hrefRange.length - 7)]; stylePair.styleValue = url; } else if([tagName isEqualToString:@"mention"]) { [styleArr addObject:@([MentionStyle getStyleType])]; @@ -657,7 +668,7 @@ - (NSArray *)getTextAndStylesFromHtml:(NSString *)fixedHtml { } else if([tagName isEqualToString:@"blockquote"]) { [styleArr addObject:@([BlockQuoteStyle getStyleType])]; } else { - // some other external tags like span just don't get put into the processed styles + // some other external tags like span just don't get put into the processed styles continue; } From 7229c3afe8bac304dd763be0ce90e3bdbd55a5ad Mon Sep 17 00:00:00 2001 From: szydlovsky <9szydlowski9@gmail.com> Date: Wed, 19 Nov 2025 11:13:59 +0100 Subject: [PATCH 2/2] fix: bring back a comment --- ios/inputParser/InputParser.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/inputParser/InputParser.mm b/ios/inputParser/InputParser.mm index 01a85a3d4..17b06e8d9 100644 --- a/ios/inputParser/InputParser.mm +++ b/ios/inputParser/InputParser.mm @@ -623,6 +623,7 @@ - (NSArray *)getTextAndStylesFromHtml:(NSString *)fixedHtml { NSRange hrefRange = match.range; [styleArr addObject:@([LinkStyle getStyleType])]; + // cut only the url from the href="..." string NSString *url = [params substringWithRange:NSMakeRange(hrefRange.location + 6, hrefRange.length - 7)]; stylePair.styleValue = url; } else if([tagName isEqualToString:@"mention"]) {