java.lang.Object
net.i2p.router.news.NewsXMLParser
Parser for I2P news feeds in Atom format with security filtering.
Processes news.xml files following RFC4287 Atom specification using the UPnP XML parser library with enhanced security features. Handles news entries, metadata, CRL entries, and blocklist data with configurable XHTML filtering.
Provides comprehensive validation and sanitization of news content with support for multiple content types and security levels. Includes configurable handling of potentially dangerous XHTML elements and attributes.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe action taken when encountering a non-whitelisted XHTML element or blacklisted attribute in the feed content.Constructor Summary
ConstructorsConstructorDescriptionCreates a new NewsXMLParser with the given context.Method Summary
Modifier and TypeMethodDescriptionThe blocklist entries.The news CRL entries.The news entries.The news metatdata.Helper to get all Nodes matching the name.static voidCommand-line entry point for testing.Process the XML file.parse(InputStream in) Process the XML input stream.voidSets the action taken when encountering a non-whitelisted XHTML element in the feed content.
Constructor Details
NewsXMLParser
Creates a new NewsXMLParser with the given context.- Parameters:
ctx- the application context supplying the log manager and property lookups
Method Details
setXHTMLMode
Sets the action taken when encountering a non-whitelisted XHTML element in the feed content. Must be set before parse(). Default REMOVE_ELEMENT.- Parameters:
mode- the XHTML mode to set
parse
Process the XML file.- Parameters:
file- XML content only. Any su3 or gunzip handling must have already happened.- Returns:
- the root node
- Throws:
IOException- on any parse error
parse
Process the XML input stream.- Parameters:
in- XML content only. Any su3 or gunzip handling must have already happened.- Returns:
- the root node
- Throws:
IOException- on any parse error
getEntries
getMetadata
The news metatdata. Must call parse() first.- Returns:
- null if parse failed
getCRLEntries
getBlocklistEntries
The blocklist entries. Must call parse() first.- Returns:
- null if none
getNodes
main
Command-line entry point for testing.- Parameters:
args- the feed file to parse, optionally followed by an XHTMLMode name