[TYPO3-core] RFC #8264 t3editor: "+" (plus) signs are replaced by spaces

Dmitry Dulepov [typo3] dmitry at typo3.org
Thu May 1 10:22:26 CEST 2008


Hi!

Martin Kutschker wrote:
> Tobias Liebig schrieb:
>>
>> Problem:
>> this issue only happens when not using UTF-8 in BE
>> it's somehow related to 0006827 <http://bugs.typo3.org/view.php?id=6827>
>> for this i substituted "encodeURIComponent" with "escape" when charset
>> is not UTF-8.
> 
> This is bogus! While encodeURIComponent() operates on utf-8 escape() 
> uses iso-8859-1. Both functions convert the local chracter set of the 
> page to their "native" charsets. Their decode conterparts do likewise in 
> the other direction.

I searched the net and I agree to Masi. This is what I found (best description) at [1]:
---------------------
You’ll often see escape() used to prepare the string for use in a URL; it escapes characters like the ampersand that would otherwise result in a malformed URL. However, escape() doesn’t handle characters outside the ASCII range correctly, so the receiving script won’t be able to interpret them. You simply can’t use escape() on Unicode text.

Luckily, all recent browsers support two new JavaScript functions, encodeURIComponent() and encodeURI(). These functions are safe for UTF-8 text, encoding them with the proper escape sequence, as well as everything escape() did to make sure the text is usable in a URL. The encodeURI() function encodes entire URIs — so it leaves characters such as :?& intact. encodeURIComponent() encodes strings to be individual parameters of a URI, so it encodes all characters except ~!*()’.

In short, if you’re using escape(), use encodeURIComponent() instead.
---------------------

So my question to Tobias is: what happens if we do not replace encodeURIComponent with escape (or escapeplus) at all? It seems to me that this replacement is not needed at all.

[1] http://www.dangrossman.info/2007/05/25/handling-utf-8-in-javascript-php-and-non-utf8-databases/
-- 
Dmitry Dulepov
TYPO3 core team
Web: http://typo3bloke.net/
Skype: callto:liels_bugs
"Nothing is impossible. There are only limits to our knowledge"


More information about the TYPO3-team-core mailing list