Fixes #2807 - Stop inserting string attributes to code blocks.
This commit is contained in:
committed by
Stefan Ceriu
parent
f5ef7a0682
commit
3bab870e5b
@@ -170,21 +170,7 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
if let value = value as? UIColor,
|
||||
value == temporaryCodeBlockMarkingColor {
|
||||
attributedString.addAttribute(.backgroundColor, value: UIColor(.compound._bgCodeBlock) as Any, range: range)
|
||||
// Codebloks should not have explicit links
|
||||
attributedString.enumerateAttribute(.link, in: range, options: []) { value, range, _ in
|
||||
if let link = value as? URL {
|
||||
var text = attributedString.attributedSubstring(from: range).string
|
||||
if !text.contains("://") {
|
||||
// we sanitize links by always them use https://
|
||||
text.insert(contentsOf: "https://", at: text.startIndex)
|
||||
}
|
||||
if text == link.absoluteString {
|
||||
attributedString.removeAttribute(.link, range: range)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Codeblocks should not have all users mentions
|
||||
attributedString.removeAttribute(.MatrixAllUsersMention, range: range)
|
||||
attributedString.removeAttribute(.link, range: range)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,6 +250,11 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
return
|
||||
}
|
||||
|
||||
// Don't add any extra attributes within codeblocks
|
||||
if attributedString.attribute(.backgroundColor, at: match.range.location, effectiveRange: nil) as? UIColor == temporaryCodeBlockMarkingColor {
|
||||
return
|
||||
}
|
||||
|
||||
switch match.type {
|
||||
case .atRoom:
|
||||
attributedString.addAttribute(.MatrixAllUsersMention, value: true, range: match.range)
|
||||
|
||||
Reference in New Issue
Block a user