You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2021. It is now read-only.
An exception is thrown from the SyndicationPerson constructor when an author or contributor element is empty. This can be seen at http://adamsitnik.com/feed.xml:
Valid name or email is required.
On the one hand this makes sense given that an empty element suggests a problem with the feed. On the other hand, most RSS readers are designed to be forgiving and this seems like something that could easily and correctly be dealt with for the user.
For anyone else who needs it, I resolved it for now by creating a special parser that just removes authors and contributors if they don't contain an email or name:
public class NoAuthorAtomParser : AtomParser
{
public override IAtomEntry CreateEntry(ISyndicationContent content)
{
// Remove author and contributor entries if they don't contain an email or name
ICollection<ISyndicationContent> children = (ICollection<ISyndicationContent>)content.Fields;
ISyndicationContent author = children.FirstOrDefault(x => x.Name == AtomContributorTypes.Author);
if(author != null
&& author.Fields.FirstOrDefault(x => x.Name == "name")?.Value == null
&& author.Fields.FirstOrDefault(x => x.Name == "email")?.Value == null)
{
children.Remove(author);
}
ISyndicationContent contributor = children.FirstOrDefault(x => x.Name == AtomContributorTypes.Contributor);
if (contributor != null
&& contributor.Fields.FirstOrDefault(x => x.Name == "name")?.Value == null
&& contributor.Fields.FirstOrDefault(x => x.Name == "email")?.Value == null)
{
children.Remove(contributor);
}
return base.CreateEntry(content);
}
}
That's not an appropriate general solution though. I propose that the parser skip person entities when there isn't any content instead of throwing.