W3C home > Mailing lists > Public > public-html@w3.org > January 2010

Re: <iframe doc="">

From: Michael A. Puls II <shadow2531@gmail.com>
Date: Mon, 25 Jan 2010 03:40:05 -0500
To: "Tab Atkins Jr." <jackalmage@gmail.com>, "Julian Reschke" <julian.reschke@gmx.de>
Cc: "Shelley Powers" <shelley.just@gmail.com>, "Ian Hickson" <ian@hixie.ch>, "public-html@w3.org WG" <public-html@w3.org>
Message-ID: <op.u62yc3l51ejg13@sandra-svwliu01>
On Sun, 24 Jan 2010 17:41:42 -0500, Tab Atkins Jr. <jackalmage@gmail.com>  
wrote:

> The answer, by the way, is no.  I can't speak for other languages, but
> PHP's standard url escaping function, urlencode(), will escape spaces
> as +.  data: urls require spaces to be encoded as %20.

In JS, data: is as easy as:

<meta charset="utf-8">
"data:text/html;charset=utf-8," + encodeURIComponent(s);

"data:text/html;charset=utf-8;base64, +  
encodeURIComponent(SomeBase64EncodeFunction(s));

(optionally doing s.replace(/\r\n|\r|\n/g, "\r\n") to normalize newlines  
first. Technically, for the first one, I think you are encouraged to do  
that so the URI is representing newlinews as %0D%0A and not juse %0A for  
example. Some URI validator might even warn you if you don't.)

For the second one, you still have to do the encodeURIComponent just in  
case any chars in the base64 string need to be percent-encoded. It's  
usually just a few though, but you still have to do it.

And, as Thomas mentioned, for php, rawurlencode/decode are basically  
always used for non-http stuff (like mailto for example) so '+' doesn't  
get confused with ' '. But, you're right. Many, many people mistakenly use  
just urlencode/decode, even seasoned developers that normally only work  
with HTTP URIs.

-- 
Michael
Received on Monday, 25 January 2010 08:40:44 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:45:08 UTC