forked from Silverfish/proton-bridge
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-363 Drafts are not deleted when already created on webapp.
|
||||||
* GODT-390 Don't logout user if AuthRefresh fails because internet was off
|
* GODT-390 Don't logout user if AuthRefresh fails because internet was off
|
||||||
* GODT-341 Fixed flaky unittest for Store synchronization cooldown
|
* 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)
|
## [v1.2.7] Donghai-hotfix - beta (2020-05-07)
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package message
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
escape "html"
|
escape "html"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -40,6 +41,10 @@ func stripHTML(input string) (stripped string, err error) {
|
|||||||
reader := strings.NewReader(input)
|
reader := strings.NewReader(input)
|
||||||
doc, _ := html.Parse(reader)
|
doc, _ := html.Parse(reader)
|
||||||
body := cascadia.MustCompile("body").MatchFirst(doc)
|
body := cascadia.MustCompile("body").MatchFirst(doc)
|
||||||
|
if body == nil {
|
||||||
|
err = errors.New("failed to find necessary html element")
|
||||||
|
return
|
||||||
|
}
|
||||||
var buf1 bytes.Buffer
|
var buf1 bytes.Buffer
|
||||||
if err = html.Render(&buf1, body); err != nil {
|
if err = html.Render(&buf1, body); err != nil {
|
||||||
stripped = input
|
stripped = input
|
||||||
|
|||||||
Reference in New Issue
Block a user