Skip to content

Commit

Permalink
Merge pull request #79 from thomas-huet/master
Browse files Browse the repository at this point in the history
Accept entries with empty author
  • Loading branch information
dinosaure authored Jan 14, 2019
2 parents e4d7b74 + 84e4615 commit 8c48110
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/syndic_atom.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let text_construct_of_xml ~xmlbase

type author = {name: string; uri: Uri.t option; email: string option}

let dummy_author = {name= ""; uri= None; email= None}
let empty_author = {name= ""; uri= None; email= None}
let not_empty_author a = a.name <> "" || a.uri <> None || a.email <> None
let author ?uri ?email name = {uri; email; name}

Expand Down Expand Up @@ -828,6 +828,8 @@ type feed' =
| `Updated of updated
| `Entry of entry ]

let dummy_name = "\000"

let make_entry ~pos l =
let authors =
List.fold_left
Expand Down Expand Up @@ -865,7 +867,7 @@ let make_entry ~pos l =
"<entry> does not contain an <author> and its <source> neither does"
in
raise (Error.Error (pos, msg)) )
| [], None -> (dummy_author, [])
| [], None -> ({name= dummy_name; uri= None; email= None}, [])
(* unacceptable value, see fix_author below *)
(* atomCategory* *)
in
Expand Down Expand Up @@ -1104,7 +1106,7 @@ let make_feed ~pos (l : _ list) =
(* atomEntry* *)
let fix_author pos (e : entry) =
match e.authors with
| a, [] when a.name = "" -> (
| a, [] when a.name = dummy_name -> (
(* In an Atom Feed Document, the atom:author elements of the containing
atom:feed element are considered to apply to the entry if there are no
atom:author elements in the locations described above.
Expand Down Expand Up @@ -1303,7 +1305,7 @@ let set_main_author_entry author (e : entry) =
let authors =
match remove_empty_authors (a0 :: a) with
| a0 :: a -> (a0, a)
| [] -> ((if author_ok then author else dummy_author), [])
| [] -> ((if author_ok then author else empty_author), [])
in
let contributors = remove_empty_authors e.contributors in
{e with authors; contributors; source}
Expand Down

0 comments on commit 8c48110

Please sign in to comment.