Class LauncherLinkPolicy
Decides whether a link found in launcher news content may be handed to the operating system's URL handler, and opens it when it may.
public static class LauncherLinkPolicy
- Inheritance
-
LauncherLinkPolicy
- Inherited Members
Remarks
This is a security boundary, not a formatting concern. The news document is fetched from
LauncherHtmlUrl, an operator-configured
endpoint, so every href in it is untrusted input that ends up at
OpenURL(string) — which will happily invoke a registered protocol
handler for schemes like javascript:, file:, or an arbitrary
application-registered scheme.
It is deliberately separate from the view that renders the news rather than inlined into it. Screening a URL is a security decision, not a presentation one, and keeping it apart means a second renderer — or a rewritten one — cannot quietly acquire its own copy. Two copies of an allowlist drift, and a drifted allowlist is a vulnerability.
Methods
OpenIfSafe(string)
Opens link in the default browser when
TryGetSafeUrl(string, out string) allows it. Rejected links are logged and ignored.
public static void OpenIfSafe(string link)
Parameters
linkstringThe raw href from the news document.
TryGetSafeUrl(string, out string)
Returns true when link is an absolute http or https URI, and
outputs its normalised form.
public static bool TryGetSafeUrl(string link, out string safeUrl)
Parameters
linkstringThe raw href from the news document.
safeUrlstringThe normalised absolute URI when allowed; otherwise null.
Returns
- bool
True when the link is safe to open.
Remarks
Deliberately strict. An earlier implementation tested whether the string merely
contained "http", which accepted javascript: payloads, local file://
paths, and any custom scheme that happened to embed those four characters
(chrome-http-pwn://…). Parse it properly and check the scheme.