aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2019-02-28 21:22:58 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2019-02-28 21:23:33 -0800
commit6764a420b0b135e55bcf885eb4bd2031bf5f7604 (patch)
tree1cad46f3d35441ce85282a515424caa7d2fff1f7 /reader
parent45df254fe74ec42d426b00b1dcfb9a274bca08dd (diff)
Make parser compatible with Go 1.12
See changes in strings.Map(): https://golang.org/doc/go1.12#strings
Diffstat (limited to 'reader')
-rw-r--r--reader/parser/parser.go26
-rw-r--r--reader/parser/parser_test.go5
2 files changed, 4 insertions, 27 deletions
diff --git a/reader/parser/parser.go b/reader/parser/parser.go
index 30fc603..726f355 100644
--- a/reader/parser/parser.go
+++ b/reader/parser/parser.go
@@ -8,7 +8,6 @@ import (
"strings"
"miniflux.app/errors"
- "miniflux.app/logger"
"miniflux.app/model"
"miniflux.app/reader/atom"
"miniflux.app/reader/json"
@@ -18,8 +17,6 @@ import (
// ParseFeed analyzes the input data and returns a normalized feed object.
func ParseFeed(data string) (*model.Feed, *errors.LocalizedError) {
- data = stripInvalidXMLCharacters(data)
-
switch DetectFeedFormat(data) {
case FormatAtom:
return atom.Parse(strings.NewReader(data))
@@ -33,26 +30,3 @@ func ParseFeed(data string) (*model.Feed, *errors.LocalizedError) {
return nil, errors.NewLocalizedError("Unsupported feed format")
}
}
-
-func stripInvalidXMLCharacters(input string) string {
- return strings.Map(func(r rune) rune {
- if isInCharacterRange(r) {
- return r
- }
-
- logger.Debug("Strip invalid XML characters: %U", r)
- return -1
- }, input)
-}
-
-// Decide whether the given rune is in the XML Character Range, per
-// the Char production of http://www.xml.com/axml/testaxml.htm,
-// Section 2.2 Characters.
-func isInCharacterRange(r rune) (inrange bool) {
- return r == 0x09 ||
- r == 0x0A ||
- r == 0x0D ||
- r >= 0x20 && r <= 0xDF77 ||
- r >= 0xE000 && r <= 0xFFFD ||
- r >= 0x10000 && r <= 0x10FFFF
-}
diff --git a/reader/parser/parser_test.go b/reader/parser/parser_test.go
index b7a93c5..a5a79a9 100644
--- a/reader/parser/parser_test.go
+++ b/reader/parser/parser_test.go
@@ -187,7 +187,10 @@ func TestDifferentEncodingWithResponse(t *testing.T) {
}
r := &client.Response{Body: bytes.NewReader(content), ContentType: tc.contentType}
- r.EnsureUnicodeBody()
+ if encodingErr := r.EnsureUnicodeBody(); encodingErr != nil {
+ t.Fatalf(`Encoding error for %q: %v`, tc.filename, encodingErr)
+ }
+
feed, parseErr := ParseFeed(r.String())
if parseErr != nil {
t.Fatalf(`Parsing error for %q - %q: %v`, tc.filename, tc.contentType, parseErr)