Link previews

A link card can show a picture: a screenshot of the page, when you sent it from the tab, or else the preview image the site names for link cards (og:image and the like). Getting that image means midden fetching from the open web on its own, which is the one thing midden does that you didn't directly ask for. This page describes what it fetches, what it refuses to reach, and what that doesn't cover.

When it fetches

What a fetch is

Two requests at most: the page, for its <head>, then the image it names.

What it won't reach

A public page can redirect, or name a preview image somewhere else. midden refuses anything that isn't http(s) to a public host:

How (the extension)

Two layers, either of which stops it:

  1. The address is checked before fetching, and again after: the page's URL, the image's URL, and where a redirect ended up. A response that landed off the public web is thrown away unread.
  2. Browser rules block the request at every hop, redirects included, before it connects. fetch() follows redirects without showing the hops, so the check in (1) only sees the end of the chain. These are declarativeNetRequest session rules, limited to midden's own requests: one per kind of address above, and the named suffixes as requestDomains.

Previews fail closed. They run only once every guard rule is confirmed in place. If the browser refuses the rules, or they can't be read back, previews stay off and the console says why ([midden] preview guard failed; link previews stay off). The pages check before fetching; the service worker checks before handing a job to the offscreen document, which can't see the rules itself.

Chrome compiles each rule's pattern with RE2 under a 2 KB memory cap and rejects the whole set if any one is over. The patterns are kept to one kind of address each, measured at about 1.4–1.6 KB, and a test fails if one grows much longer.

How (the phone)

The app follows no redirects on its own (disableRedirects): each hop's address is checked before it's requested, so nothing private is ever contacted.

What this doesn't cover