forked from Silverfish/proton-bridge
fix(GODT-2473): Fix handling of complex mime types
When rebuilding attachments, ensure that more complicated mime types are properly re-constructed. If we fail to parse the mime type, set the value as is.
This commit is contained in:
@ -793,7 +793,8 @@ func TestBuildAttachmentWithLongFilename(t *testing.T) {
|
||||
expectHeader(`Content-Type`, contains(veryLongName)).
|
||||
expectContentDispositionParam(`filename`, is(veryLongName)).
|
||||
expectHeader(`Content-Disposition`, contains(veryLongName)).
|
||||
expectSection(hasMaxLineLength(215))
|
||||
// GODT-2477 - Implement line splitting according to RFC-2184.
|
||||
expectSection(hasMaxLineLength(426))
|
||||
}
|
||||
|
||||
func TestBuildMessageDate(t *testing.T) {
|
||||
@ -1231,3 +1232,38 @@ func readFile(t *testing.T, path string) string {
|
||||
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func TestBuildComplexMIMEType(t *testing.T) {
|
||||
m := gomock.NewController(t)
|
||||
defer m.Finish()
|
||||
|
||||
kr := utils.MakeKeyRing(t)
|
||||
msg := newTestMessage(t, kr, "messageID", "addressID", "text/html", "<html><body>body</body></html>", time.Now())
|
||||
att0 := addTestAttachment(t, kr, &msg, "attachID0", "attach0.png", "image/png", "attachment", "attach0")
|
||||
att1 := addTestAttachment(t, kr, &msg, "attachID1", "Cat_August_2010-4.jpeg", "image/jpeg; name=Cat_August_2010-4.jpeg; x-unix-mode=0644", "attachment", "attach1")
|
||||
|
||||
res, err := BuildRFC822(kr, msg, [][]byte{
|
||||
att0,
|
||||
att1,
|
||||
}, JobOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
section(t, res, 1).
|
||||
expectBody(is(`<html><body>body</body></html>`)).
|
||||
expectContentType(is(`text/html`)).
|
||||
expectTransferEncoding(is(`quoted-printable`))
|
||||
|
||||
section(t, res, 2).
|
||||
expectBody(is(`attach0`)).
|
||||
expectContentType(is(`image/png`)).
|
||||
expectTransferEncoding(is(`base64`)).
|
||||
expectContentTypeParam(`name`, is(`attach0.png`)).
|
||||
expectContentDispositionParam(`filename`, is(`attach0.png`))
|
||||
|
||||
section(t, res, 3).
|
||||
expectBody(is(`attach1`)).
|
||||
expectContentType(is(`image/jpeg`)).
|
||||
expectTransferEncoding(is(`base64`)).
|
||||
expectContentTypeParam(`name`, is(`Cat_August_2010-4.jpeg`)).
|
||||
expectContentDispositionParam(`filename`, is(`Cat_August_2010-4.jpeg`))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user