mirror of
				https://github.com/nkanaev/yarr.git
				synced 2025-11-04 08:48:45 +00:00 
			
		
		
		
	remove bom
This commit is contained in:
		@@ -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.
 | 
			
		||||
 | 
			
		||||
- blogger
 | 
			
		||||
- cnblogs
 | 
			
		||||
- flickr
 | 
			
		||||
- hatenablog
 | 
			
		||||
- livejournal
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ type processor func(r io.Reader) (*Feed, error)
 | 
			
		||||
 | 
			
		||||
func sniff(lookup string) (string, processor) {
 | 
			
		||||
	lookup = strings.TrimSpace(lookup)
 | 
			
		||||
	lookup = strings.TrimLeft(lookup, "\x00\xEF\xBB\xBF\xFE\xFF")
 | 
			
		||||
	switch lookup[0] {
 | 
			
		||||
	case '<':
 | 
			
		||||
		decoder := xmlDecoder(strings.NewReader(lookup))
 | 
			
		||||
 
 | 
			
		||||
@@ -92,3 +92,18 @@ func TestParseShortFeed(t *testing.T) {
 | 
			
		||||
		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()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user