forked from Silverfish/proton-bridge
refactor: don't reconstruct mimeBody
This commit is contained in:
@ -1,3 +1,20 @@
|
||||
// Copyright (c) 2020 Proton Technologies AG
|
||||
//
|
||||
// This file is part of ProtonMail Bridge.
|
||||
//
|
||||
// ProtonMail Bridge is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ProtonMail Bridge is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package parser
|
||||
|
||||
import (
|
||||
@ -34,11 +51,11 @@ func (p *Part) AddChild(child *Part) {
|
||||
p.children = append(p.children, child)
|
||||
}
|
||||
|
||||
func (p *Part) isUTF8() bool {
|
||||
return utf8.Valid(p.Body)
|
||||
}
|
||||
func (p *Part) ConvertToUTF8() error {
|
||||
if utf8.Valid(p.Body) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Part) convertToUTF8() error {
|
||||
t, params, err := p.Header.ContentType()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -57,7 +74,7 @@ func (p *Part) convertToUTF8() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: Is this okay? What about when the charset is embedded in structured text type eg html/xml?
|
||||
// HELP: Is this okay? What about when the charset is embedded in structured text type eg html/xml?
|
||||
params["charset"] = "utf-8"
|
||||
p.Header.SetContentType(t, params)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user