mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 12:46:46 +00:00
fix: crash if fail to find necessary html element
This commit is contained in:
@ -22,6 +22,7 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
||||
* GODT-363 Drafts are not deleted when already created on webapp.
|
||||
* GODT-390 Don't logout user if AuthRefresh fails because internet was off
|
||||
* GODT-341 Fixed flaky unittest for Store synchronization cooldown
|
||||
* Crash when failing to match necessary html element
|
||||
|
||||
## [v1.2.7] Donghai-hotfix - beta (2020-05-07)
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ package message
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
escape "html"
|
||||
"strings"
|
||||
|
||||
@ -40,6 +41,10 @@ func stripHTML(input string) (stripped string, err error) {
|
||||
reader := strings.NewReader(input)
|
||||
doc, _ := html.Parse(reader)
|
||||
body := cascadia.MustCompile("body").MatchFirst(doc)
|
||||
if body == nil {
|
||||
err = errors.New("failed to find necessary html element")
|
||||
return
|
||||
}
|
||||
var buf1 bytes.Buffer
|
||||
if err = html.Render(&buf1, body); err != nil {
|
||||
stripped = input
|
||||
|
||||
Reference in New Issue
Block a user