mmcdole / gofeed

Parse RSS, Atom and JSON feeds in Go
MIT License
2.51k stars 204 forks source link

Fix RSS enclosure parsing #218

Closed sgodart closed 4 months ago

sgodart commented 6 months ago

Fix #217 Ignore all child nodes of <enclosure>, not only TextNodes.

mmcdole commented 6 months ago

@sgodart can you include a test that demonstrates the issue at hand you are encountering?

I saw your issue you created. A test where it fails and is broken, and this PR fixes, would be much appreciated.

sgodart commented 6 months ago

Hey @mmcdole, thanks for your reply. Here is a code snippet to reproduce, you should see "Error parsing feed..." in stdout :

package main

import (
    "fmt"

    "github.com/mmcdole/gofeed"
)

func main() {
    parser := gofeed.NewParser()
    _, err := parser.ParseURL("https://sportauto.autojournal.fr/feed")

    if err != nil {
        fmt.Printf("Error parsing feed: %s\n", err.Error())
    } else {
        fmt.Printf("No error\n")
    }
}

The same snippet using this PR should output "No error", adding this statement in your go.mod:

replace github.com/mmcdole/gofeed => github.com/ividence/gofeed v1.2.2
sgodart commented 5 months ago

hey @mmcdole, any update on this?

mmcdole commented 4 months ago

@sgodart greetings!

I appreciate the further details, but I was really asking for a new unit test, if you could, along with the patch.

They are specified with minimal feed representations and the expected output. So, for this, it would be a feed with an enclosure with a media tag (or similar), and then the specified parsed output.

https://github.com/mmcdole/gofeed/tree/master/testdata/parser/rss

That helps ensure any refactoring or future changes catch this issue as well and that we don't regress.

sgodart commented 4 months ago

Hey @mmcdole, thanks again for your help. I've added the test files. Have a nice day.