Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latte: escape url in css in style attribute #1407

Open
hrach opened this issue Feb 16, 2014 · 6 comments
Open

Latte: escape url in css in style attribute #1407

hrach opened this issue Feb 16, 2014 · 6 comments

Comments

@hrach
Copy link
Contributor

hrach commented Feb 16, 2014

<div style="background-image: url({$img});">

escapes output almost correctly, but the escape of space is missing.

<div style="background-image: url(\/\/img\.example\.com\/upload\/test file\.jpg);">

nette 06c27ba

@hrach
Copy link
Contributor Author

hrach commented Apr 22, 2014

cc @dg do you know how to fix this?

@mishak87
Copy link
Contributor

This looks fishy.

Some characters appearing in an unquoted URI, such as parentheses, white space characters, single quotes (') and double quotes ("), must be escaped with a backslash so that the resulting URI value is a URI token: '(', ')'.
CSS2

Dot and forward slash should not be escaped, also whitespace before and after value is allowed so it should not be escaped either.

Since it allows for unclear interpretation, there should be escaping context CSS PLAIN URL (escape whitespace, parenthesis, quote, double quote and maybe backslash), CSS QUOTED STRING (escape quote and backslash) and CSS DOUBLE QUOTED STRING (escape double quote and backslash) with according escaping.

I am not sure what is implemented, take this as a checklist.

@JanTvrdik
Copy link
Contributor

The whole escapeCss does not work properly, because there are many possible contexts in CSS alone and we recognize only one.

@hrach
Copy link
Contributor Author

hrach commented Aug 16, 2014

cc @dg do you plan to fix this? otherwise I would close it...

@dg
Copy link
Member

dg commented May 16, 2016

I do not want to develop CSS parser, so the question is whether to start escaping whitespace globally in CSS is OK or not. The opposite problem #1512

@hrach
Copy link
Contributor Author

hrach commented May 17, 2016

if I recall it correctly, <div style="background-image: url('{$img}');"> fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants