mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
remove bom
This commit is contained in:
parent
42b36965c5
commit
fbb0dfed47
@ -152,6 +152,7 @@ The parser should be reasonably handle content provided by them.
|
|||||||
Delete any from the list in case they drop support of web feeds.
|
Delete any from the list in case they drop support of web feeds.
|
||||||
|
|
||||||
- blogger
|
- blogger
|
||||||
|
- cnblogs
|
||||||
- flickr
|
- flickr
|
||||||
- hatenablog
|
- hatenablog
|
||||||
- livejournal
|
- livejournal
|
||||||
|
@ -17,6 +17,7 @@ type processor func(r io.Reader) (*Feed, error)
|
|||||||
|
|
||||||
func sniff(lookup string) (string, processor) {
|
func sniff(lookup string) (string, processor) {
|
||||||
lookup = strings.TrimSpace(lookup)
|
lookup = strings.TrimSpace(lookup)
|
||||||
|
lookup = strings.TrimLeft(lookup, "\x00\xEF\xBB\xBF\xFE\xFF")
|
||||||
switch lookup[0] {
|
switch lookup[0] {
|
||||||
case '<':
|
case '<':
|
||||||
decoder := xmlDecoder(strings.NewReader(lookup))
|
decoder := xmlDecoder(strings.NewReader(lookup))
|
||||||
|
@ -92,3 +92,18 @@ func TestParseShortFeed(t *testing.T) {
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseFeedWithBOM(t *testing.T) {
|
||||||
|
have, err := Parse(strings.NewReader(
|
||||||
|
"\xEF\xBB\xBF" + `<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"></feed>`,
|
||||||
|
))
|
||||||
|
want := &Feed{}
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(want, have) {
|
||||||
|
t.Logf("want: %#v", want)
|
||||||
|
t.Logf("have: %#v", have)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user