File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -510,12 +510,18 @@ func isQuotedPrintableEncoding(value string) bool {
510510 if value == "" {
511511 return false
512512 }
513+ // Handle potential parameters defensively, though RFC 2045 doesn't define them.
513514 if idx := strings .Index (value , ";" ); idx != - 1 {
514515 value = value [:idx ]
515516 }
516517 return strings .EqualFold (strings .TrimSpace (value ), "quoted-printable" )
517518}
518519
520+ // shouldSkipQuotedPrintable returns true when QP decoding should be skipped.
521+ // This handles emails where Content-Transfer-Encoding is declared as quoted-printable
522+ // but the body is already decoded. Applying QP decoding to such content corrupts
523+ // '=' characters (e.g., in URLs). We detect this by checking if raw is valid UTF-8
524+ // but decoded becomes invalid (indicating the decoder treated literal '=' as escapes).
519525func shouldSkipQuotedPrintable (raw , decoded []byte , charsetLabel string ) bool {
520526 if ! isUTF8Charset (charsetLabel ) {
521527 return false
You can’t perform that action at this time.
0 commit comments