Hi,

In using the feedparser API I've encountered a number of RSS feeds that are missing the lenght attribute for enclosures. This causes feedparser to throw a NPE. The standard does say that length is a required element, but in practice it's being ignored. I've attached a patch if anyone is interested. The length if not provided in the feed is set to 0.

You'll need to apply the patches I submited yesterday first.

Cheers,
Andrew McCall
Index: src/java/org/apache/commons/feedparser/RSSFeedParser.java
===================================================================
--- src/java/org/apache/commons/feedparser/RSSFeedParser.java   (revision 
365922)
+++ src/java/org/apache/commons/feedparser/RSSFeedParser.java   (working copy)
@@ -297,7 +297,9 @@
         String type = element.getAttributeValue( "type" );
         String href = element.getAttributeValue( "url" );
         String title = null;
-        long length = Integer.parseInt( element.getAttributeValue( "length" ) 
);
+        long length = 0;
+        if (element.getAttributeValue("length") != null)
+               length = Integer.parseInt( element.getAttributeValue( "length" 
) );
 
         linkFeedParserListener.onLink( state,
                                        rel,

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to