New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fall Back to Entry id if Entry Links Do Not Exist #11
Conversation
lib/post.ml
Outdated
@@ -163,7 +163,7 @@ let post_of_atom ~(feed : Feed.t) (e : Syndic.Atom.entry) = | |||
(List.find (fun l -> l.Syndic.Atom.rel = Syndic.Atom.Alternate) e.links) | |||
.href | |||
with Not_found -> ( | |||
match e.links with l :: _ -> Some l.href | [] -> None) | |||
match e.links with l :: _ -> Some l.href | [] -> Some e.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that id is a valid URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.ietf.org/rfc/rfc4287.txt
It seems that, even if the URI is valid, there's no guarantee that a resource can be fetched via HTTP (i.e. it's allowed for Atom feeds to declare resources that are not dereferencable).
4.2.6. The "atom:id" Element
The "atom:id" element conveys a permanent, universally unique
identifier for an entry or feed.
atomId = element atom:id {
atomCommonAttributes,
(atomUri)
}
Its content MUST be an IRI, as defined by [RFC3987]. Note that the
definition of "IRI" excludes relative references. Though the IRI
might use a dereferencable scheme, Atom Processors MUST NOT assume it
can be dereferenced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check on the URI scheme, so that we only recognise this as a link if the scheme is "http" or "https".
cb52385
to
572ae42
Compare
With these changes, the feed from ocaml/ocaml.org#1776 is consumed successfully. |
Thank you! |
CHANGES: - Fall back to entry id if entry links doesn't exist (tarides/river#11, @sabine)
It is legal for an Atom feed to not have
links
.In this case, it appears sensible to rely on the value provided by the
id
tag.