Fix in reply to links appearing outside of mx-quote

This commit is contained in:
aringenbach
2022-06-03 15:51:24 +02:00
committed by aringenbach
parent 9aa6902397
commit 83ebb6e462
2 changed files with 11 additions and 2 deletions
@@ -29,7 +29,7 @@
#import "MXKRoomNameStringLocalizer.h"
static NSString *const kHTMLATagRegexPattern = @"<a href=\"(.*?)\">([^<]*)</a>";
static NSString *const kHTMLATagRegexPattern = @"<a href=(?:'|\")(.*?)(?:'|\")>([^<]*)</a>";
@interface MXKEventFormatter ()
{
@@ -1843,6 +1843,14 @@ static NSString *const kHTMLATagRegexPattern = @"<a href=\"(.*?)\">([^<]*)</a>";
*/
- (NSString*)renderReplyTo:(NSString*)htmlString withRoomState:(MXRoomState*)roomState
{
NSInteger mxReplyEndLocation = [htmlString rangeOfString:@"</mx-reply>"].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 = @"<a href=\"(.*?)\">([^<]*)</a>";
[htmlATagRegex enumerateMatchesInString:html
options:0
range:NSMakeRange(0, html.length)
range:NSMakeRange(0, mxReplyEndLocation)
usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop) {
if (hrefCount > 1)