Skip to main content

parse_with_limits

Function parse_with_limits 

Source
pub fn parse_with_limits(
    data: &[u8],
    limits: ParserLimits,
) -> Result<ParsedFeed>
Expand description

Parse feed with custom parser limits

This allows controlling resource usage when parsing untrusted feeds. HTML sanitization and relative URI resolution use their crate::ParseOptions::default settings (both enabled); use parse_with_options to control them directly.

§Examples

use feedparser_rs::{parse_with_limits, ParserLimits};

let xml = b"<rss version=\"2.0\"><channel><title>Test</title></channel></rss>";
let limits = ParserLimits::strict();
let feed = parse_with_limits(xml, limits).unwrap();

§Errors

Returns FeedError::InvalidFormat if data exceeds limits.max_feed_size_bytes, or the error of a parser that cannot continue. An unrecognized format is not an error; it sets bozo.