MeridianMERIDIAN

Data URI

technology.internet.data_uri

Inline data URI scheme embedding content directly in a string. Format: data:[mediatype][;base64],data. Used for embedding small files in HTML, CSS, and API responses.

Worked samples

DuckDB 1.5.5 · finetype 0.6.64

ValueAs VARCHARis_base64media_type
data:text/plain;base64,SGVsbG8gV29ybGQ=data:text/plain;base64,SGVsbG8gV29ybGQ=Truetext/plain
data:image/png;base64,iVBORw0KGgoAAAANSUhEUg==data:image/png;base64,iVBORw0KGgoAAAANSUhEUg==Trueimage/png
data:application/json,{"key":"value"}data:application/json,{"key":"value"}Falseapplication/json
data:text/html,%3Ch1%3EHello%3C%2Fh1%3Edata:text/html,%3Ch1%3EHello%3C%2Fh1%3EFalsetext/html

Shape

Pattern
^data:(?:[a-zA-Z0-9]+/[a-zA-Z0-9\-+.]+)?(?:;[a-zA-Z0-9\-]+=[^;,]*)*(?:;base64)?,.+$
ValueLengthShape
data:text/plain;base64,SGVsbG8gV29ybGQ=39matches
data:image/png;base64,iVBORw0KGgoAAAANSUhEUg==46matches
data:application/json,{"key":"value"}37matches
data:text/html,%3Ch1%3EHello%3C%2Fh1%3E39matches
data.text/plain;base64,SGVsbG8gV29ybGQ=39rejected: separator swapped

Background

Origin

The data URL scheme is defined in RFC 2397, The "data" URL scheme, published in August 1998.[1] RFC 2397 was written by L. Masinter of Xerox Corporation.[1] RFC 2397 says the scheme exists because some applications that use URLs need to embed small media type data directly inline.[1] RFC 2397 describes the scheme as working like 'immediate addressing'.[1] RFC 2397 records that the idea was originally proposed in August 1995.[1] RFC 2397 says some versions of the data URL scheme have been used in the definition of VRML.[1] RFC 2397 notes that quoted-printable was dropped as an encoding because it would not easily yield valid URLs without additional %xx encoding.[1]

RFC 2397 gives the form data:[<mediatype>][;base64],<data>.[1] Under RFC 2397, an omitted media type defaults to text/plain;charset=US-ASCII.[1] RFC 2397 says the ;base64 extension is told apart from a content-type parameter by having no following = sign.[1] RFC 2397 says the data URL scheme is only useful for short values.[1]

The Fetch Standard from the WHATWG states that its data: URL section replaces RFC 2397's normative processing requirements, to be compatible with deployed content.[2] MDN says data URLs were formerly known as data URIs until that name was retired by the WHATWG.[3]

Use

MDN describes data URLs as allowing content creators to embed small files inline in documents.[3] The CSS url() function accepts a data URL as its parameter, according to MDN.[4] RFC 2397 shows a data URL used as the SRC of an HTML IMG element to carry a small inline GIF image.[1] Wikipedia notes that Base64-encoded data is approximately 33% larger than the original data.[5]

Without ;base64, RFC 2397 says octets outside the range of safe URL characters are written with the standard %xx hex encoding of URLs.[1] Wikipedia notes that Base64-encoded data URIs use the standard Base64 character set, with + and /, rather than the URL-safe Base64 alphabet.[5] MDN warns that invalid parameters in the media type, or typos in base64, are ignored without any error.[3] The Fetch Standard's processor falls back to text/plain;charset=US-ASCII when the media type cannot be parsed.[2]

MDN reports that Chromium and Firefox limit data URLs to 512MB, and Safari (WebKit) limits them to 2048MB.[3] MDN reports that top-level navigation to data: URLs is blocked in all modern browsers, because of security issues such as phishing.[3] RFC 2397 says interpreting a data URL carries the same security considerations as any implementation of its media type.[1] Treat a decoded data URI as an untrusted file of the type it claims, and check the decoded bytes rather than trusting the declared media type. (Meridian's view)

Sources

  1. [1]The "data" URL schemestandard
  2. [2]Fetch Standardstandard
  3. [3]data: URLs - URIs | MDNdocumentation
  4. [4]url() CSS function - CSS | MDNdocumentation
  5. [5]data URI scheme - Wikipediasecondary source

Detection notes

Media type is optional (defaults to text/plain;charset=US-ASCII). Base64 encoding is indicated by ;base64 before the comma.

Use it

CLI · DuckDB
$ finetype infer -i "data:text/plain;base64,SGVsbG8gV29ybGQ=" --mode column
→ technology.internet.data_uri

SELECT ft_infer('data:text/plain;base64,SGVsbG8gV29ybGQ=');
-- → 'technology.internet.data_uri'
Cast expression
CAST({col} AS VARCHAR)

Schema

https://meridian.online/schemas/technology.internet.data_uri · Frictionless type string · uri

finetype taxonomy technology.internet.data_uri -o json-schema

Type Registry