Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name with a dot causes Spamassassin's FROM_EXCESS_BASE64 to fire #4

Closed
mariancerny opened this Issue Aug 14, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@mariancerny
Copy link

mariancerny commented Aug 14, 2014

Setting $message->from to "hokuspokus.cz <info@hokuspokus.cz>" causes the following header to be generated:

From: =?UTF-8?B?aG9rdXNwb2t1cy5jeg==?= <info@hokuspokus.cz>

This however causes Spamassassin to fire the rule FROM_EXCESS_BASE64=0.979, which means "From: base64 encoded unnecessarily"
https://wiki.apache.org/spamassassin/Rules/FROM_EXCESS_BASE64

@mariancerny

This comment has been minimized.

Copy link
Author

mariancerny commented Aug 14, 2014

I can see in MimePart.php, that the encoding is forced when name contains the following characters: .,;<@>()[]"=?

$s .= self::encodeHeader($name, $offset, strpbrk($name, '.,;<@>()[]"=?'));

I understand that it is forced for a reason, but I think that for the case of a plain domain name (single word containing only dots) it should not be escaped.

The definition of the FROM_EXCESS_BASE64 rule in Spamassassin is:

meta FROM_EXCESS_BASE64         __FROM_ENCODED_B64 && !__FROM_NEEDS_MIME
header __FROM_ENCODED_B64       From:raw =~ /=\?\S+\?B\?/i
header __FROM_NEEDS_MIME        From =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/
@dg

This comment has been minimized.

Copy link
Member

dg commented Aug 14, 2014

Special chars like dot must be in quoted string, according to RFC 822. Or encoded as base64. This can be somehow changed, but Nette encodes strings when they may exceed 80 chars boundary and Spamassassin seems to not accept even this.

@mariancerny

This comment has been minimized.

Copy link
Author

mariancerny commented Aug 17, 2014

Observation: Apple Mail (version 7.3) does not encode sender name in From header when it contains a dot:

From: "example.com" <info@example.com>
@mariancerny

This comment has been minimized.

Copy link
Author

mariancerny commented Aug 17, 2014

RFC 822 has been obsoleted by RFC 2822.

If I am reading RFC 2822 correctly, then the name (display-name) does not need to be base64/quoted-printable encoded, just quoted-string (a string in quotes) when it contains the dot (.) character.

Also, those special characters '.,;<@>()[]"=?' in MimePart.php are missing :\ (see specials bellow). In addition =? are there extra. But I understand that is probably there because =? is used for base64/quoted-printable encoding.

So I think that sending mail with name 'example.com'

$mail = new Message;
$mail->setFrom('info@example.com', 'example.com')

should generate header

From: "example.com" <info@example.com>

Relevant parts from RFC 2822:

from            =       "From:" mailbox-list CRLF

mailbox-list    =       (mailbox *("," mailbox)) / obs-mbox-list

mailbox         =       name-addr / addr-spec

name-addr       =       [display-name] angle-addr

display-name    =       phrase

phrase          =       1*word / obs-phrase

word            =       atom / quoted-string

atom            =       [CFWS] 1*atext [CFWS]

atext           =       ALPHA / DIGIT / ; Any character except controls,
                        "!" / "#" /     ;  SP, and specials.
                        "$" / "%" /     ;  Used for atoms
                        "&" / "'" /
                        "*" / "+" /
                        "-" / "/" /
                        "=" / "?" /
                        "^" / "_" /
                        "`" / "{" /
                        "|" / "}" /
                        "~"

quoted-string   =       [CFWS]
                        DQUOTE *([FWS] qcontent) [FWS] DQUOTE
                        [CFWS]

qcontent        =       qtext / quoted-pair

qtext           =       NO-WS-CTL /     ; Non white space controls

                        %d33 /          ; The rest of the US-ASCII
                        %d35-91 /       ;  characters not including "\"
                        %d93-126        ;  or the quote character

specials        =       "(" / ")" /     ; Special characters used in
                        "<" / ">" /     ;  other parts of the syntax
                        "[" / "]" /
                        ":" / ";" /
                        "@" / "\" /
                        "," / "." /
                        DQUOTE

@dg dg closed this in 278b687 Aug 18, 2014

dg added a commit that referenced this issue Aug 18, 2014

dg added a commit that referenced this issue Aug 18, 2014

dg added a commit that referenced this issue Aug 18, 2014

dg added a commit that referenced this issue Aug 24, 2014

dg added a commit that referenced this issue Aug 24, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 25, 2014

dg added a commit to nette/nette that referenced this issue Aug 27, 2014

dg added a commit to nette/nette that referenced this issue Aug 27, 2014

dg added a commit to nette/nette that referenced this issue Aug 28, 2014

dg added a commit to nette/nette that referenced this issue Aug 28, 2014

dg added a commit to nette/nette that referenced this issue Aug 28, 2014

dg added a commit to nette/nette that referenced this issue Aug 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.