Expand description
Feed fetch → parse → sanitize → store pipeline.
This is the module that turns a feed URL into rows in the store. It is
deliberately conservative on three axes, because a feed reader ingests
hostile, arbitrary web input:
- Politeness — fetches use a conditional GET (
If-None-Match/If-Modified-Sincefrom the storedETag/Last-Modified), an identifiablecrate::USER_AGENT, a request timeout, and a simple exponential backoff hint on error. A304 Not Modifiedis a no-op: the feed is untouched apart from bumping its next-poll time. - Safety — every entry’s HTML is run through
ammoniabefore it is ever stored (and therefore before it is ever rendered). Scripts, event handlers,javascript:URLs, tracking pixels’ dangerous attributes, and other XSS vectors are stripped. Feeds carrying<script>is not hypothetical; treat all feed HTML as untrusted. - Robustness — a malformed feed is logged and skipped, never a
panic. One bad publisher must not take down the poller. All non-test
paths use
Result/anyhow; there are nounwrap/expects.
The normalized shape written to the store is the store’s own
store::NewFeed / store::NewEntry; dedup is by feed-native GUID via
store::insert_entries’s ON CONFLICT (feed_id, guid) upsert.
Enums§
- Feed
Privacy - The privacy classification of a feed URL — the output of
classify_feed_privacy. - Poll
Outcome - The outcome of polling a single feed. Lets the scheduler decide how to reschedule (and lets tests assert what happened) without inspecting the DB.
Functions§
- backoff_
for - Compute the backoff for the
nth consecutive failure (1-based), clamped to [BACKOFF_MAX]. Exponential in the error count so transient blips retry soon while a durably-broken feed backs off toward daily. - build_
client - Build a
reqwest::Clientconfigured for polite and safe feed fetching. - classify_
feed_ privacy - Classify whether a feed URL carries a secret credential in the URL itself.
- discover_
feed - Discover a feed URL from a site’s HTML via
<link rel="alternate" type="application/rss+xml|atom+xml" href="…">. - poll_
feed - Fetch, parse, sanitize, normalize, and store a single feed.