You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It fails on newer versions of go (1.14.7 and later, possibly earlier).
The go 1.15 implementation contains the following code block in ParseDate(string) (lines 110-120 of mail/message.go, as of the time of writing):
// RFC 5322: zone = (FWS ( "+" / "-" ) 4DIGIT) / obs-zone
// zone length is always 5 chars unless obsolete (obs-zone)
if ind := strings.IndexAny(p.s, "+-"); ind != -1 && len(p.s) >= ind+5 {
date = p.s[:ind+5]
p.s = p.s[ind+5:]
} else if ind := strings.Index(p.s, "T"); ind != -1 && len(p.s) >= ind+1 {
// The last letter T of the obsolete time zone is checked when no standard time zone is found.
// If T is misplaced, the date to parse is garbage.
date = p.s[:ind+1]
p.s = p.s[ind+1:]
}
When executing the above test, we enter the else case, and because the string begins with T for Tue, the variable date ends up with value "T" and p.s ends up with "ue, 21 Aug 2018 13:41:49 GMT".
The function then continues and executes the following loop (lines 124-129 of mail/message.go):
for _, layout := range dateLayouts {
t, err := time.Parse(layout, date)
if err == nil {
return t, nil
}
}
This should succeed, because dateLayouts does indeed contain a matching layout (namely Mon, 2 Jan 2006 15:04:05 MST), but by this point date has been reduced to just T, so it fails.
I feel that the first block of code, which checks the placement of T, shouldn't break the date string, as in the test case provided above.
Go 1.13 did not contain the above mentioned block of code that reduces date down to "T" and thus successfully parses the provided date string.
The text was updated successfully, but these errors were encountered:
jameshoulahan
changed the title
Regression in implementation of mail.ParseDate(...)
Regression in implementation of mail.ParseDate(...)
Oct 6, 2020
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
I expected it to pass, as it did on go 1.13.
What did you see instead?
It fails on newer versions of go (1.14.7 and later, possibly earlier).
The go 1.15 implementation contains the following code block in
ParseDate(string)
(lines 110-120 of mail/message.go, as of the time of writing):When executing the above test, we enter the
else
case, and because the string begins withT
forTue
, the variabledate
ends up with value"T"
andp.s
ends up with"ue, 21 Aug 2018 13:41:49 GMT"
.The function then continues and executes the following loop (lines 124-129 of mail/message.go):
This should succeed, because
dateLayouts
does indeed contain a matching layout (namelyMon, 2 Jan 2006 15:04:05 MST
), but by this pointdate
has been reduced to justT
, so it fails.I feel that the first block of code, which checks the placement of
T
, shouldn't break the date string, as in the test case provided above.Go 1.13 did not contain the above mentioned block of code that reduces
date
down to"T"
and thus successfully parses the provided date string.The text was updated successfully, but these errors were encountered: