mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
hicli/sync: skip linkifying for messages with no special characters
This commit is contained in:
parent
8a34618a70
commit
15d696ae09
1 changed files with 13 additions and 4 deletions
|
@ -383,10 +383,19 @@ func (h *HiClient) calculateLocalContent(ctx context.Context, dbEvt *database.Ev
|
|||
inlineImages = nil
|
||||
}
|
||||
} else {
|
||||
hasSpecialCharacters := false
|
||||
for _, char := range content.Body {
|
||||
if char == '<' || char == '>' || char == '&' || char == '.' || char == ':' {
|
||||
hasSpecialCharacters = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if hasSpecialCharacters {
|
||||
var builder strings.Builder
|
||||
builder.Grow(len(content.Body) + builderPreallocBuffer)
|
||||
linkifyAndWriteBytes(&builder, []byte(content.Body))
|
||||
sanitizedHTML = builder.String()
|
||||
}
|
||||
wasPlaintext = true
|
||||
}
|
||||
return &database.LocalContent{
|
||||
|
|
Loading…
Add table
Reference in a new issue