springuser2014 / wro4j

Automatically exported from code.google.com/p/wro4j
0 stars 0 forks source link

CSS url rewriting creates incorrect urls for CSS rules that include quoted urls #91

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Include a group that contains stylesheet including a background image:

.inlineHelp {
    background:#B3B3B3 url("/images/buttons/button_gry_bg.png") repeat-x scroll 0 -1px;
}

2. View a page that uses the style. In firebug, note you get a 404 for the 
image because it's 
looking for:
/styles/styles/<groupName>/images/buttons/button_gry_bg.png

What is the expected output? What do you see instead?

Image should be referenced correctly. Note that the CSS spec allows for 
optional quotes, so they 
should be handled:
http://www.w3.org/TR/CSS2/syndata.html#uri

What version of the product are you using?
1.2.7

Original issue reported on code.google.com by david.hi...@gmail.com on 17 May 2010 at 3:01

GoogleCodeExporter commented 9 years ago
Could you specify the location of the stylesheet containing the .inlineHelp 
class? It 
is important, because the way the url is rewritten depends on the css location. 

Regarding quotes handling: I don't quite understand the problem, as long as the 
url is 
rewritten even if you use the quotes. Do you mean that the output should 
contain the 
quotes as the input does?  

Original comment by alex.obj...@gmail.com on 18 May 2010 at 7:41

GoogleCodeExporter commented 9 years ago
One more question: what do you mean by image should be referenced correctly? 
What is 
the correct url of the image? 

I wouldn't recommend to start the background image url with "/" character, 
because that 
wouldn't make it relative to css but to app root context which may lead to 
unexpected 
behavior (when you deploy your application under a different context). 

Original comment by alex.obj...@gmail.com on 18 May 2010 at 8:19

GoogleCodeExporter commented 9 years ago
The CSS is at /styles/combinable/tooltips.css.

Here's my wro.xml:

  <group name="combined">
    <js>/scripts/combinable/**.js</js>
    <css>/styles/combinable/**.css</css>
  </group>

The correct url is just /images/buttons/button_gry_bg.png as specified in the 
CSS file. So no url rewriting is 
necessary, and none happens when I omit the quotes in the CSS rule. But when I 
add quotes, the url rewriting 
seems to kick in and lead to a 404.

Original comment by david.hi...@gmail.com on 18 May 2010 at 9:09

GoogleCodeExporter commented 9 years ago
Indeed, you are right. When quotes are used, the url doesn't work consistently. 
Thanks 
for reporting this!

Original comment by alex.obj...@gmail.com on 18 May 2010 at 10:05

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 18 May 2010 at 10:05

GoogleCodeExporter commented 9 years ago
Fixed - when the background image url starts with '/', it won't be overwritten 
no 
matter if quotes are used or not.

Original comment by alex.obj...@gmail.com on 18 May 2010 at 10:17

GoogleCodeExporter commented 9 years ago
The fix seems to be specific only to the resources whose uri is a valid 
ServletContext resource.(ie. if the css belongs to the servlet context)

The bug still remains for conditions where you have the css hosted in an 
external server (ie. when we use the UrlUriLocator)

The fix probably should have been made in the 
CssUrlRewritingProcessor.computeNewImageLocation(), the image url starts with 
the '/' it should have left alone, shouldn't it ?

Original comment by doncarea...@gmail.com on 13 Jun 2012 at 6:50