YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.ShareUriPolicy Class Reference

Decides which shared text may become a playable URI. More...

Collaboration diagram for de.yaacc.browser.ShareUriPolicy:
Collaboration graph

Static Public Member Functions

static boolean isAllowed (String text)
 
static String extractUrl (String text)
 
static String hostOf (String url)
 The host of an http or https link as the picker shows it, in lower case, or null if the link has no usable host.
 

Static Public Attributes

static final int MAX_TEXT_LENGTH = 2048
 Longer texts are dropped, not truncated.
 

Detailed Description

Decides which shared text may become a playable URI.

Plain Java so it can be unit tested on the JVM.

The text comes from another app and is untrusted. With the proxy option on, a file:// or bare-path URI would be served to the whole LAN through the local proxy, so only http and https links are accepted. Apps share a link inside a text ("Look at this https://...") as often as alone, so the first link is picked out of the text: it starts with http:// or https:// (compared as ASCII, no locale or Unicode case folding) at the start of the text or after white space or an opening bracket or quote, it ends at the first white space or control character, trailing punctuation is not part of it, and it has a host. Nothing after the link is used.

Member Function Documentation

◆ extractUrl()

static String de.yaacc.browser.ShareUriPolicy.extractUrl ( String text)
static
Parameters
textthe shared text, may be null
Returns
the first http or https link of the text, or null if the text is empty, longer than MAX_TEXT_LENGTH or has no link with a host

Referenced by de.yaacc.browser.ShareIntentHandler.handle(), and de.yaacc.browser.ShareUriPolicy.isAllowed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hostOf()

static String de.yaacc.browser.ShareUriPolicy.hostOf ( String url)
static

The host of an http or https link as the picker shows it, in lower case, or null if the link has no usable host.

A user name in front of it (trusted.com@evil.example) is not the host.

Parameters
urla link such as extractUrl(String) returns, may be null

Referenced by de.yaacc.browser.ShareUriPolicy.extractUrl().

Here is the caller graph for this function:

◆ isAllowed()

static boolean de.yaacc.browser.ShareUriPolicy.isAllowed ( String text)
static
Parameters
textthe shared text, may be null
Returns
true if the text contains a usable http or https link, see extractUrl(String)
Here is the call graph for this function:

The documentation for this class was generated from the following file: