Skip to content

Commit

Permalink
Let original Element kRepliedTextPattern in place for use in `rende…
Browse files Browse the repository at this point in the history
…rPollEndedReplyTo` method.
  • Loading branch information
NicolasBuquet committed Jun 13, 2024
1 parent 3b29e87 commit 28acf2b
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
#import "GeneratedInterface-Swift.h"

static NSString *const kHTMLATagRegexPattern = @"<a href=(?:'|\")(.*?)(?:'|\")>([^<]*)</a>";
// Tchap: modify regex to define reply paqttern
// static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*)</blockquote></mx-reply>";
// The Tchap pattern takes in account:
static NSString *const kRepliedTextPattern = @"<mx-reply>.*<blockquote>.*<br>(.*)</blockquote></mx-reply>";
// Tchap: modify regex to define reply pattern// The Tchap pattern takes in account:
// - a text can span on multiple lines -> (?s) modifier make regex '.' to match any char or newline char.
// - the pattern doesn't truncate any quoted user defined by <a> tag at the begining of the replied to text
// else, truncating in first quoted users (if they exists) breaks the tyext rendering.
static NSString *const kRepliedTextPattern = @"(?s)<mx-reply>.*<blockquote>.*<br>(?:<a .*?/a>[: ]*)*(.*)</blockquote></mx-reply>";
static NSString *const kTchapRepliedTextPattern = @"(?s)<mx-reply>.*<blockquote>.*<br>(?:<a .*?/a>[: ]*)*(.*)</blockquote></mx-reply>";

@interface MXKEventFormatter ()
{
Expand Down Expand Up @@ -2057,7 +2056,7 @@ - (NSString *)tchapTruncatedQuotedReplyFrom:(NSString *)fullQuotedReply {

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
htmlQuotedTextRegex = [NSRegularExpression regularExpressionWithPattern:kRepliedTextPattern
htmlQuotedTextRegex = [NSRegularExpression regularExpressionWithPattern:kTchapRepliedTextPattern
options:NSRegularExpressionCaseInsensitive
error:nil];
});
Expand Down

0 comments on commit 28acf2b

Please sign in to comment.