Skip to content

Commit 97c327b

Browse files
committed
fix: add a check that the href attribute exists in link params
1 parent a16c4d0 commit 97c327b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

ios/inputParser/InputParser.mm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,12 @@ - (NSArray *)getTextAndStylesFromHtml:(NSString *)fixedHtml {
597597
} else if([tagName isEqualToString:@"code"]) {
598598
[styleArr addObject:@([InlineCodeStyle getStyleType])];
599599
} else if([tagName isEqualToString:@"a"]) {
600-
[styleArr addObject:@([LinkStyle getStyleType])];
601-
// cut only the url from the href="..." string
602-
NSString *url = [params substringWithRange:NSMakeRange(6, params.length - 7)];
603-
stylePair.styleValue = url;
600+
[styleArr addObject:@([LinkStyle getStyleType])];
601+
NSRange hrefRange = [params rangeOfString:@"href="];
602+
if(hrefRange.location != NSNotFound) {
603+
NSString *url = [params substringWithRange:NSMakeRange(6, params.length - 7)];
604+
stylePair.styleValue = url;
605+
}
604606
} else if([tagName isEqualToString:@"mention"]) {
605607
[styleArr addObject:@([MentionStyle getStyleType])];
606608
// extract html expression into dict using some regex

0 commit comments

Comments
 (0)