SlyMarbo / rss

A Go library for fetching, parsing, and updating RSS feeds.
Other
399 stars 85 forks source link

make enclosure return error on parsing 'none' value #66

Closed vasconcelosvcd closed 6 years ago

vasconcelosvcd commented 6 years ago

Sorry about the last pull request got some troubles on my git.

check if that was what you were meaning, I've got a little confuse about that answer.

Thanks!

SlyMarbo commented 6 years ago

This is definitely moving in a good direction. At the moment, if there is an error, we just return the error and no data. As some people will want to ignore the error, I think it would be better if we return the data and the error. That way, people can choose to ignore the error or not.

ghost commented 6 years ago

The length attribute of enclosure must be a positive integer for the RSS 2.0 feed to be valid. I've made up a feed that has length="none" and it fails to validate: http://www.feedvalidator.org/check.cgi?url=https%3A%2F%2Fwww.lhorn.de%2Ffeed%2Ffefe.enclosure.rss.xml

So I am not sure if the library should fix invalid feeds. Maybe we should think about a 'strict' vs. a 'relaxed' mode: In strict mode only valid feeds are parsed without errors. In relaxed mode invalid feeds throw an error. What do you think?

vasconcelosvcd commented 6 years ago

I think its a nice idea but, if the library starts to correct every single invalid feeds it will start to be a Frankenstein code.

that just my point of view.

ghost commented 6 years ago

I agree. That's why I'd tend to be more strict and let the parsing of an item with <enclosure length="none" .../> fail.

But this is a design question. Is there a general pattern how invalid feeds are dealt with?

vasconcelosvcd commented 6 years ago

I think it's simple, let them just fail. if they're invalid...

I know in most cases who's using the library is not the maintainer of the feed, but make an library go rogue like that, is just not right...

Again, my point of view

ghost commented 6 years ago

@SlyMarbo What do you think? What was your approach so far in dealing with invalid feeds?

SlyMarbo commented 6 years ago

So far I've generally erred on the side of correctness. I could go either way here but I think rejecting invalid feeds is probably for the best.

On Tue, 6 Mar 2018, 8:39 pm Lutz Horn, notifications@github.com wrote:

@SlyMarbo https://github.com/slymarbo What do you think? What was your approach so far in dealing with invalid feeds?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/SlyMarbo/rss/pull/66#issuecomment-370920309, or mute the thread https://github.com/notifications/unsubscribe-auth/ABhJQidOltsa2sjzPkHAw1FuQ07Brt8Dks5tbvQMgaJpZM4SfRun .