pub struct ParseOptions {
pub resolve_relative_uris: bool,
pub sanitize_html: bool,
pub limits: ParserLimits,
}Expand description
Parser configuration options
Controls various aspects of feed parsing behavior including URL resolution,
HTML sanitization, and resource limits for DoS protection.
§Examples
use feedparser_rs::ParseOptions;
// Default options (recommended for most use cases)
let options = ParseOptions::default();
assert!(options.resolve_relative_uris);
assert!(options.sanitize_html);
// Custom options for restricted environment
let custom = ParseOptions {
resolve_relative_uris: true,
sanitize_html: false, // Trust feed content
limits: feedparser_rs::ParserLimits::strict(),
};Fields§
§resolve_relative_uris: boolWhether to resolve relative URLs to absolute URLs
When true, relative URLs in links, images, and other resources
are converted to absolute URLs using the feed’s base URL.
Default: true
§Examples
use feedparser_rs::ParseOptions;
let mut options = ParseOptions::default();
options.resolve_relative_uris = false; // Keep relative URLssanitize_html: boolWhether to sanitize HTML content in feed entries
When true, HTML content in titles, summaries, and content blocks
is sanitized to remove potentially dangerous elements and attributes
(scripts, iframes, etc.) while preserving safe formatting.
Default: true
§Security
Disabling HTML sanitization is not recommended unless you fully trust the feed source and have other security measures in place.
§Examples
use feedparser_rs::ParseOptions;
let mut options = ParseOptions::default();
options.sanitize_html = false; // Disable for trusted feedslimits: ParserLimitsParser limits for DoS protection
Controls maximum allowed sizes for collections, text fields, and overall feed size to prevent resource exhaustion attacks.
Default: ParserLimits::default()
§Examples
use feedparser_rs::{ParseOptions, ParserLimits};
let options = ParseOptions {
limits: ParserLimits::strict(), // Use stricter limits
..Default::default()
};Implementations§
Source§impl ParseOptions
impl ParseOptions
Sourcepub const fn permissive() -> Self
pub const fn permissive() -> Self
Creates permissive parse options
Suitable for trusted feeds where you want maximum compatibility and performance:
resolve_relative_uris:truesanitize_html:falselimits:ParserLimits::permissive()
§Security Warning
Use only with trusted feed sources!
§Examples
use feedparser_rs::ParseOptions;
let options = ParseOptions::permissive();
assert!(!options.sanitize_html);Sourcepub const fn strict() -> Self
pub const fn strict() -> Self
Creates strict parse options
Suitable for untrusted feeds in resource-constrained environments:
resolve_relative_uris:false(preserve original URLs)sanitize_html:true(remove dangerous content)limits:ParserLimits::strict()(tight resource limits)
§Examples
use feedparser_rs::ParseOptions;
let options = ParseOptions::strict();
assert!(options.sanitize_html);
assert!(!options.resolve_relative_uris);Trait Implementations§
Source§impl Clone for ParseOptions
impl Clone for ParseOptions
Source§fn clone(&self) -> ParseOptions
fn clone(&self) -> ParseOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more