mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-25 05:29:20 +00:00
increase lookup length
This commit is contained in:
parent
f126247262
commit
36bc84d99a
@ -43,7 +43,7 @@ func sniff(lookup string) (string, processor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Parse(r io.Reader) (*Feed, error) {
|
func Parse(r io.Reader) (*Feed, error) {
|
||||||
lookup := make([]byte, 1024)
|
lookup := make([]byte, 2048)
|
||||||
n, err := io.ReadFull(r, lookup)
|
n, err := io.ReadFull(r, lookup)
|
||||||
switch {
|
switch {
|
||||||
case err == io.ErrUnexpectedEOF:
|
case err == io.ErrUnexpectedEOF:
|
||||||
|
@ -83,3 +83,35 @@ func TestRSSMediaContentThumbnail(t *testing.T) {
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRSSWithLotsOfSpaces(t *testing.T) {
|
||||||
|
// https://pxlnv.com/: https://feedpress.me/pxlnv
|
||||||
|
feed, err := Parse(strings.NewReader(strings.ReplaceAll(`
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?xml-stylesheet type="text/xsl" media="screen" href="/~files/feed-premium.xsl"?>
|
||||||
|
<lotsofspaces>
|
||||||
|
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
||||||
|
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||||
|
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
|
||||||
|
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
|
||||||
|
xmlns:feedpress="https://feed.press/xmlns"
|
||||||
|
xmlns:media="http://search.yahoo.com/mrss/"
|
||||||
|
version="2.0">
|
||||||
|
<channel>
|
||||||
|
<title>finally</title>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
|
`, "<lotsofspaces>", strings.Repeat(" ", 500))))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
have := feed.Title
|
||||||
|
want := "finally"
|
||||||
|
if have != want {
|
||||||
|
t.Logf("want: %#v", want)
|
||||||
|
t.Logf("have: %#v", have)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user