Hey all,
I'm currently researching ways to safely encode in all browsers URLs and strings in CSS found in HTML. For example,
* url(http://example.com) with backslash escaping of quotes and parentheses as \" and \) is insecure because Internet Explorer doesn't recognize those kinds of character escapes
* 'Font name' with backslash escaping of single quotes is insecure for the same reason.
I currently have the following scheme:
* Given a URL to insert into url(), check that it is properly URL encoded (in particular, a doublequote and backslash never occurs within it) and then place it as url("http://example.com").
* Given a font name, if it is strictly alphanumeric, it is safe to omit quotes. Otherwise, wrap in double quotes and replace '"' with '\22 ' (note trailing space) and '\' with '\5C ' (ditto).
Ways to break these schemes, or potentially valid names that are broken by the scheme on certain browsers, would be appreciated.
Thanks,
Edward
HTML Purifier - Standards Compliant HTML filtering