diff --git a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m index 28b127af7..9ff5ef2b2 100644 --- a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m +++ b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m @@ -29,7 +29,7 @@ #import "MXKRoomNameStringLocalizer.h" -static NSString *const kHTMLATagRegexPattern = @"([^<]*)"; +static NSString *const kHTMLATagRegexPattern = @"([^<]*)"; @interface MXKEventFormatter () { @@ -1843,6 +1843,14 @@ static NSString *const kHTMLATagRegexPattern = @"([^<]*)"; */ - (NSString*)renderReplyTo:(NSString*)htmlString withRoomState:(MXRoomState*)roomState { + NSInteger mxReplyEndLocation = [htmlString rangeOfString:@""].location; + + if (mxReplyEndLocation == NSNotFound) + { + MXLogWarning(@"[MXKEventFormatter] Missing mx-reply block in html string"); + return htmlString; + } + NSString *html = htmlString; static NSRegularExpression *htmlATagRegex; @@ -1860,7 +1868,7 @@ static NSString *const kHTMLATagRegexPattern = @"([^<]*)"; [htmlATagRegex enumerateMatchesInString:html options:0 - range:NSMakeRange(0, html.length) + range:NSMakeRange(0, mxReplyEndLocation) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop) { if (hrefCount > 1) diff --git a/changelog.d/4586.bugfix b/changelog.d/4586.bugfix new file mode 100644 index 000000000..bca3ee68e --- /dev/null +++ b/changelog.d/4586.bugfix @@ -0,0 +1 @@ +Fix in reply to links appearing outside of mx-quote