add todo's about mime header parameter decoding

not sure what the correct approach is, would need to analyze email archive for practices.
This commit is contained in:
Mechiel Lukkien 2023-09-21 14:51:47 +02:00
parent f87f286b80
commit 79774c15ec
No known key found for this signature in database
4 changed files with 4 additions and 2 deletions

View file

@ -135,6 +135,7 @@ type Attachment struct {
// File name based on "name" attribute of "Content-Type", or the "filename" // File name based on "name" attribute of "Content-Type", or the "filename"
// attribute of "Content-Disposition". // attribute of "Content-Disposition".
// todo: decode non-ascii character sets
Filename string Filename string
Part message.Part Part message.Part

View file

@ -1954,7 +1954,7 @@
}, },
{ {
"Name": "Filename", "Name": "Filename",
"Docs": "File name based on \"name\" attribute of \"Content-Type\", or the \"filename\" attribute of \"Content-Disposition\".", "Docs": "File name based on \"name\" attribute of \"Content-Type\", or the \"filename\" attribute of \"Content-Disposition\". todo: decode non-ascii character sets",
"Typewords": [ "Typewords": [
"string" "string"
] ]

View file

@ -322,7 +322,7 @@ export interface MessageEnvelope {
// viewable text or HTML part. // viewable text or HTML part.
export interface Attachment { export interface Attachment {
Path?: number[] | null // Indices into top-level message.Part.Parts. Path?: number[] | null // Indices into top-level message.Part.Parts.
Filename: string // File name based on "name" attribute of "Content-Type", or the "filename" attribute of "Content-Disposition". Filename: string // File name based on "name" attribute of "Content-Type", or the "filename" attribute of "Content-Disposition". todo: decode non-ascii character sets
Part: Part Part: Part
} }

View file

@ -212,6 +212,7 @@ func parsedMessage(log *mlog.Log, m store.Message, state *msgState, full, msgite
disp, params, err := mime.ParseMediaType(cp) disp, params, err := mime.ParseMediaType(cp)
log.Check(err, "parsing content-disposition", mlog.Field("cp", cp)) log.Check(err, "parsing content-disposition", mlog.Field("cp", cp))
if strings.EqualFold(disp, "attachment") { if strings.EqualFold(disp, "attachment") {
// todo: should we be decoding these names? i've seen messages with regular q-word style mime-encoding, not the one specified in ../rfc/2231:210
name := p.ContentTypeParams["name"] name := p.ContentTypeParams["name"]
if name == "" { if name == "" {
name = params["filename"] name = params["filename"]