You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by th...@apache.org on 2014/05/31 00:55:28 UTC
git commit: TAP5-2187 : CSS relative URL rewriting isn't lenient
enough
Repository: tapestry-5
Updated Branches:
refs/heads/master e6eb63c57 -> 23330e4bf
TAP5-2187 : CSS relative URL rewriting isn't lenient enough
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/23330e4b
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/23330e4b
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/23330e4b
Branch: refs/heads/master
Commit: 23330e4bf581d00196f372a97685a0a27ff09b2e
Parents: e6eb63c
Author: Thiago H. de Paula Figueiredo <th...@apache.org>
Authored: Fri May 30 19:55:15 2014 -0300
Committer: Thiago H. de Paula Figueiredo <th...@apache.org>
Committed: Fri May 30 19:55:15 2014 -0300
----------------------------------------------------------------------
.../services/assets/CSSURLRewriter.java | 21 +++++----
.../services/assets/CSSURLRewriterTests.groovy | 46 ++++++++++++++++++++
2 files changed, 59 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/23330e4b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
index 95ba2ba..ae6c3b5 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
@@ -154,17 +154,22 @@ public class CSSURLRewriter extends DelegatingSRS
Asset asset = assetSource.getAsset(baseResource, url, null);
- String assetURL = asset.toClientURL();
-
- String queryParameters = matcher.group(3);
- if (queryParameters != null)
+ if (asset != null)
{
- assetURL += queryParameters;
- }
+ String assetURL = asset.toClientURL();
+
+ String queryParameters = matcher.group(3);
+ if (queryParameters != null)
+ {
+ assetURL += queryParameters;
+ }
- appendReplacement(matcher, output, assetURL);
+ appendReplacement(matcher, output, assetURL);
- didReplace = true;
+ didReplace = true;
+
+ }
+
}
if (!didReplace)
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/23330e4b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/CSSURLRewriterTests.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/CSSURLRewriterTests.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/CSSURLRewriterTests.groovy
index 6286a83..d491d64 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/CSSURLRewriterTests.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/CSSURLRewriterTests.groovy
@@ -284,4 +284,50 @@ div.busy {
}
+ // See TAP5-2187
+ @Test
+ void dont_fail_when_rewritten_url_is_not_found() {
+ def input = '''
+body {
+ background: white url("images/back.png") attach-x;
+}
+h1 {
+ background: white url("images/i_dont_exist.png") attach-x;
+}
+'''
+
+ def assetSource = newMock AssetSource
+ def resource = newMock Resource
+ def asset = newMock Asset
+
+ expect(
+ assetSource.getAsset(resource, "images/back.png", null)
+ ).andReturn asset
+
+ expect(asset.toClientURL()).andReturn "/ctx/images/back.png"
+
+ expect(
+ assetSource.getAsset(resource, "images/i_dont_exist.png", null)
+ ).andReturn null
+
+ replay()
+
+
+ def rewriter = new CSSURLRewriter(null, null, assetSource, null)
+
+ def output = rewriter.replaceURLs input, resource
+
+ assertEquals output, '''
+body {
+ background: white url("/ctx/images/back.png") attach-x;
+}
+h1 {
+ background: white url("images/i_dont_exist.png") attach-x;
+}
+'''
+
+ verify()
+
+ }
+
}