mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-06 04:20:33 +00:00
feat(core): Add message of the day. Remove all html tags except for anchor tags (mobile only)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user