Skip to content

Commit

Permalink
Add workaround to handle some invalid dates
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Mar 21, 2021
1 parent 5877048 commit e60e0ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 8 additions & 8 deletions reader/atom/atom_03.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,27 @@ func (a *atom03Entry) entryHash() string {
}

type atom03Text struct {
Type string `xml:"type,attr"`
Mode string `xml:"mode,attr"`
Data string `xml:",chardata"`
XML string `xml:",innerxml"`
Type string `xml:"type,attr"`
Mode string `xml:"mode,attr"`
CharData string `xml:",chardata"`
InnerXML string `xml:",innerxml"`
}

func (a *atom03Text) String() string {
content := ""

switch {
case a.Mode == "xml":
content = a.XML
content = a.InnerXML
case a.Mode == "escaped":
content = a.Data
content = a.CharData
case a.Mode == "base64":
b, err := base64.StdEncoding.DecodeString(a.Data)
b, err := base64.StdEncoding.DecodeString(a.CharData)
if err == nil {
content = string(b)
}
default:
content = a.Data
content = a.CharData
}

if a.Type != "text/html" {
Expand Down
2 changes: 2 additions & 0 deletions reader/date/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ var invalidLocalizedDateReplacer = strings.NewReplacer(
"mai ", "May ",
"jui ", "Jun ",
"juin ", "June ",
"Thurs,", "Thu,",
"Thur,", "Thu,",
)

// Parse parses a given date string using a large
Expand Down
2 changes: 2 additions & 0 deletions reader/date/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func TestParseWeirdDateFormat(t *testing.T) {
"2018-10-23 04:07:42 +00:00",
"5 August, 2019",
"mar., 01 déc. 2020 16:11:02 +0000",
"Thurs, 15 Oct 2020 00:00:39 +0000",
"Thur, 19 Nov 2020 00:00:39 +0000",
}

for _, date := range dates {
Expand Down

0 comments on commit e60e0ba

Please sign in to comment.