feat(core): Add message of the day. Remove all html tags except for anchor tags (mobile only)

This commit is contained in:
smizrahi
2024-01-29 17:16:08 +01:00
parent f43974bbb7
commit 455fe97cbe
4 changed files with 29 additions and 1 deletions
+22
View File
@@ -903,6 +903,28 @@ static int cssEscapingCount;
return result;
}
/**
* Remove all HTML tags except for <a> </a>
* @return A clean string
*/
- (NSString *)removeHTMLTagsExceptAnchorTags {
NSError *error;
NSRegularExpression *regex;
NSString *stringWithoutHTML;
error = nil;
regex = [NSRegularExpression regularExpressionWithPattern: @"<(?!a|\\/a\\b)[^>]*>" options: NSRegularExpressionCaseInsensitive error: &error];
stringWithoutHTML = [regex stringByReplacingMatchesInString: self options: 0 range: NSMakeRange(0, [self length]) withTemplate:@""];
if (error) {
[self logWithFormat: @"Error while removing tags : %@", [error localizedDescription]];
return self;
}
return stringWithoutHTML;
}
/**
* Get the safe string avoiding HTML injection
* @param stripHTMLCode Remove all HTML code from content