ProtonMail / proton-bridge

Proton Mail Bridge application
GNU General Public License v3.0
1.11k stars 145 forks source link

`failed to parse to [Error offset=118]; expected " for quoted string end` #454

Closed benwr closed 6 months ago

benwr commented 6 months ago

While learning to use git send-email, following the tutorial at git-send-email.io, I hit the following error:

 554 5.0.0 Error: transaction failed, blame it on the weather: failed to parse message: failed to parse message header: failed to parse to: [Error offset=118]: expected " for quoted string end

Using the -v flag, I saw that the only header with any quotes was To: "~sircmpwn/email-test-drive@lists.sr.ht". The address appears to me to have matching quote marks.

Expected Behavior

Email addressed to the address "~sircmpwn/email-test-drive@lists.sr.ht" should be delivered.

Current Behavior

I get the error above: 554 5.0.0 Error: transaction failed, blame it on the weather: failed to parse message: failed to parse message header: failed to parse to: [Error offset=118]: expected " for quoted string end

Possible Solution

This can be worked around by surrounding the address in angle brackets.

Steps to Reproduce

Follow the tutorial at git-send-email.io through Step Three.

Version Information

Context (Environment)

macOS 14.2, git 2.43.0

LBeernaertProton commented 6 months ago

Could you please capture the SMTP message headers sent to bridge?

You need to start the bridge cli with bridge -n -l=trace --log-smtp.

benwr commented 6 months ago
TRAC[Dec 29 12:58:21.937] From: Ben Weinstein-Raun <root@benwr.net>     pkg=SMTP
TRAC[Dec 29 12:58:21.937] To: "~sircmpwn/email-test-drive@lists.sr.ht"  pkg=SMTP
TRAC[Dec 29 12:58:21.937] Cc: Ben Weinstein-Raun <root@benwr.net>       pkg=SMTP
TRAC[Dec 29 12:58:21.937] Subject: [PATCH] Demonstrate that I can use git send-email  pkg=SMTP
TRAC[Dec 29 12:58:21.937] Date: Fri, 29 Dec 2023 12:58:18 -0500         pkg=SMTP
TRAC[Dec 29 12:58:21.937] Message-ID: <20231229175818.98969-1-root@benwr.net>  pkg=SMTP
TRAC[Dec 29 12:58:21.937] X-Mailer: git-send-email 2.43.0               pkg=SMTP
TRAC[Dec 29 12:58:21.937] MIME-Version: 1.0                             pkg=SMTP
TRAC[Dec 29 12:58:21.937] Content-Transfer-Encoding: 8bit               pkg=SMTP
LBeernaertProton commented 6 months ago

@benwr, the supplied address is not valid according to the RFC5322. You need to change you address to:

"~sircmpwn/email-test-drive"@lists.sr.ht
benwr commented 6 months ago

@LBeernaertProton I don't think that's correct?

From the spec:

atext = [...] ALPHA / DIGIT / [...] "-" / "/" / [...] "~"
dot-atom-text = 1*atext *("." 1*atext)

An addr-spec... contains a locally interpreted string followed by the at-sign character... followed by an internet domain. The locally interpreted string is either a quoted string or a dot-atom. If the string can be represented as a dot-atom (that is, it contains no characters other than atext characters or "." surrounded by atext characters), then the dot-atom form SHOULD be used and the quoted-string form SHOULD NOT be used.

LBeernaertProton commented 6 months ago

My understanding of that paragraph is that it is referring to local-part of the following parsing rules.

  addr-spec       =   local-part "@" domain

   local-part      =   dot-atom / quoted-string / obs-local-part

The issue with your address input is that it can be surrounded by quotes.

Both "~sircmpwn/email-test-drive"@lists.sr.ht and ~sircmpwn/email-test-drive@lists.sr.ht are valid addresses. However, "~sircmpwn/email-test-drive@lists.sr.ht" is not.

benwr commented 6 months ago

@LBeernaertProton I see, thanks for your help.

For anyone else with this problem:

I think I hit this issue because I was using a non-POSIX shell when following the tutorial, and I forgot that POSIX shells will strip the quotes from arguments (and perform expansions), while my shell doesn't. So the tutorial was expecting the argument to git send-email --to=... to be ~sircmpwn/email-test-drive@lists.sr.ht but I was handing it "~sircmpwn/email-test-drive@lists.sr.ht", which it was passing through directly to SMTP.