You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2013/05/17 02:37:24 UTC
[2/6] git commit: TAP5-2106: Do not attempt to rewrite complete URLs
TAP5-2106: Do not attempt to rewrite complete URLs
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/9d61731b
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/9d61731b
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/9d61731b
Branch: refs/heads/master
Commit: 9d61731b31bd5b25ace8f1a87acdc415e82d9328
Parents: 31e3409
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:33:14 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:33:14 2013 -0700
----------------------------------------------------------------------
.../internal/services/assets/CSSURLRewriter.java | 4 +++-
.../services/assets/CSSURLRewriterTests.groovy | 13 +++++++++++++
2 files changed, 16 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d61731b/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 cdcd847..ed9d12d 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
@@ -47,6 +47,8 @@ public class CSSURLRewriter extends DelegatingSRS
// Group 3 is any query parmameters (see issue TAP5-2106)
private final Pattern urlPattern = Pattern.compile("url\\(\\s*(['\"]?)(.+?)(\\?.*)?\\1\\s*\\)", Pattern.MULTILINE);
+ private final Pattern urlPrefixPattern = Pattern.compile("^\\p{Alpha}\\w*:");
+
private final OperationTracker tracker;
private final AssetSource assetSource;
@@ -125,7 +127,7 @@ public class CSSURLRewriter extends DelegatingSRS
// When the URL starts with a slash, there's no need to rewrite it (this is actually rare in Tapestry
// as you want to use relative URLs to leverage the asset pipeline.
- if (url.startsWith("/"))
+ if (url.startsWith("/") || urlPrefixPattern.matcher(url).find())
{
// This may normalize single quotes, or missing quotes, to double quotes, but is not
// considered a real change, since all such variations are valid.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9d61731b/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 4de7e04..bb9dc68 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
@@ -142,6 +142,19 @@ body {
}
@Test
+ void complete_urls_are_not_replaced() {
+ def input = '''
+body {
+ background: white url("data:image/png;base64,CODE64A") attach-x;
+}
+'''
+
+ def rewriter = new CSSURLRewriter(null, null, null, null)
+
+ assertNull rewriter.replaceURLs(input, null)
+ }
+
+ @Test
void absolute_urls_passed_through_unchanged() {
def input = '''