From 6bb5b53fc6aaae8515e625be6e5c1fed61f83197 Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Thu, 4 Mar 2021 19:38:24 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Push=20the=20=E2=80=9Cfixable=20flaws?= =?UTF-8?q?=E2=80=9D=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../en-us/web/http/basics_of_http/data_uris/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/files/en-us/web/http/basics_of_http/data_uris/index.html b/files/en-us/web/http/basics_of_http/data_uris/index.html index 935cd7a20c58a9c..c55ae16d9a54e09 100644 --- a/files/en-us/web/http/basics_of_http/data_uris/index.html +++ b/files/en-us/web/http/basics_of_http/data_uris/index.html @@ -46,7 +46,7 @@

Encoding data into base64 format

Encoding in Javascript

-

The Web APIs have native methods to encode or decode to base64: Base64 encoding and decoding.

+

The Web APIs have native methods to encode or decode to base64: Base64 encoding and decoding.

Encoding on a Unix system

@@ -128,10 +128,10 @@

Browser compatibility

See also

From 1fa4bd6a54c64458eeacac41e8a8faa96ea71608 Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Thu, 4 Mar 2021 19:39:01 +0900 Subject: [PATCH 2/2] Clarify what gets percent-encoded in data URLs Also fixes https://github.com/mdn/content/issues/2840 --- files/en-us/web/http/basics_of_http/data_uris/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/http/basics_of_http/data_uris/index.html b/files/en-us/web/http/basics_of_http/data_uris/index.html index c55ae16d9a54e09..c185749e3a4fbda 100644 --- a/files/en-us/web/http/basics_of_http/data_uris/index.html +++ b/files/en-us/web/http/basics_of_http/data_uris/index.html @@ -25,13 +25,15 @@

Syntax

The mediatype is a MIME type string, such as 'image/jpeg' for a JPEG image file. If omitted, defaults to text/plain;charset=US-ASCII

-

If the data is textual, you can embed the text (using the appropriate entities or escapes based on the enclosing document's type). Otherwise, you can specify base64 to embed base64-encoded binary data. You can find more info on MIME types here and here.

+

If the data contains characters defined in RFC 3986 as reserved characters, or contains space characters, newline characters, or other non-printing characters, those characters must be percent-encoded (aka “URL-encoded”).

+ +

If the data is textual, you can embed the text (using the appropriate entities or escapes based on the enclosing document's type). Otherwise, you can specify base64 to embed base64-encoded binary data. You can find more info on MIME types here and here.

A few examples:

data:,Hello%2C%20World!
-
Simple text/plain data. Note the use of percent-encoding (URL-encoding) for the quote and space characters. Also, for CSV data (MIME type "text/csv"), percent-encoding is needed to preserve the line endings that delimit rows of the spreadsheet.
+
The text/plain data Hello, World!. Note how the comma is percent-encoded as %2C, and the space character as %20.
data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==
base64-encoded version of the above
data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E