syndication: Fix atom parsing.

This is the problematic feed:
  https://rfc1149.net/blog/tag/factor/feed/

Here's the validator saying it's ok:
  https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Frfc1149.net%2Fblog%2Ftag%2Ffactor%2Ffeed%2F
freebsd-work
Doug Coleman 2019-01-12 17:52:55 -06:00
parent c3569f02fa
commit f00bc7e08c
1 changed files with 11 additions and 6 deletions

View File

@ -1,11 +1,10 @@
! Copyright (C) 2006 Chris Double, Daniel Ehrenberg. ! Copyright (C) 2006 Chris Double, Daniel Ehrenberg.
! Portions copyright (C) 2008, 2009 Slava Pestov. ! Portions copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: xml.traversal kernel assocs math.order strings sequences USING: accessors byte-arrays calendar.format calendar.parser
xml.data xml.writer io.streams.string combinators xml combinators combinators.short-circuit continuations http.client
xml.entities.html io.files io http.client namespaces make kernel present sequences strings urls xml xml.data
xml.syntax hashtables calendar.format calendar.parser accessors xml.entities.html xml.syntax xml.traversal xml.writer ;
continuations urls present byte-arrays ;
IN: syndication IN: syndication
: any-tag-named ( tag names -- tag-inside ) : any-tag-named ( tag names -- tag-inside )
@ -65,8 +64,14 @@ TUPLE: entry title url description date ;
[ "item" tags-named [ rss2.0-entry ] map set-entries ] [ "item" tags-named [ rss2.0-entry ] map set-entries ]
tri ; tri ;
ERROR: invalid-atom-link ;
: atom-link ( tag -- url/f ) : atom-link ( tag -- url/f )
"link" "alternate" "rel" tag-named-with-attr {
[ "link" "alternate" "rel" tag-named-with-attr ]
[ "link" "self" "rel" tag-named-with-attr ]
[ "link" tag-named ]
} 1||
[ "href" attr >url ] [ f ] if* ; [ "href" attr >url ] [ f ] if* ;
: atom1.0-entry ( tag -- entry ) : atom1.0-entry ( tag -- entry )