MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / decodeTransferEncoding

Function decodeTransferEncoding

internal/outbound/forward.go:139–156  ·  view source on GitHub ↗

decodeTransferEncoding decodes the Content-Transfer-Encoding wrapping of a body part. Unknown encodings pass through unchanged — better to surface raw bytes than drop the part entirely.

(data []byte, encoding string)

Source from the content-addressed store, hash-verified

137// of a body part. Unknown encodings pass through unchanged — better to
138// surface raw bytes than drop the part entirely.
139func decodeTransferEncoding(data []byte, encoding string) []byte {
140 switch strings.ToLower(strings.TrimSpace(encoding)) {
141 case "quoted-printable":
142 decoded, err := io.ReadAll(quotedprintable.NewReader(bytes.NewReader(data)))
143 if err != nil {
144 return data
145 }
146 return decoded
147 case "base64":
148 decoded, err := base64.StdEncoding.DecodeString(string(bytes.TrimSpace(data)))
149 if err != nil {
150 return data
151 }
152 return decoded
153 default:
154 return data
155 }
156}
157
158// ForwardAttachments extracts the stored attachment parts of the message being
159// forwarded and converts them to the outbound Attachment shape (base64-encoded

Callers 1

extractBodyPartsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected