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:23 UTC

[1/6] git commit: TAP5-2106: Maintain query parameters in URL

Updated Branches:
  refs/heads/master ead83fb15 -> 56a114812


TAP5-2106: Maintain query parameters in URL

In some cases, client-side code expects to see a query parameter in the URL for a CSS asset, so it should be maintained


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/31e34098
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/31e34098
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/31e34098

Branch: refs/heads/master
Commit: 31e34098e9511fb22e06a384a1fed679706ff7d0
Parents: ead83fb
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:25:43 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:25:43 2013 -0700

----------------------------------------------------------------------
 .../internal/services/assets/CSSURLRewriter.java   |    9 +++-
 .../services/assets/CSSURLRewriterTests.groovy     |   36 +++++++++++++++
 2 files changed, 44 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/31e34098/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 fc673fa..cdcd847 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
@@ -44,7 +44,8 @@ public class CSSURLRewriter extends DelegatingSRS
 {
     // Group 1 is the optional single or double quote (note the use of backtracking to match it)
     // Group 2 is the text inside the quotes, or inside the parens if no quotes
-    private final Pattern urlPattern = Pattern.compile("url\\(\\s*(['\"]?)(.+?)\\1\\s*\\)", Pattern.MULTILINE);
+    // Group 3 is any query parmameters (see issue TAP5-2106)
+    private final Pattern urlPattern = Pattern.compile("url\\(\\s*(['\"]?)(.+?)(\\?.*)?\\1\\s*\\)", Pattern.MULTILINE);
 
     private final OperationTracker tracker;
 
@@ -135,6 +136,12 @@ public class CSSURLRewriter extends DelegatingSRS
             Asset asset = assetSource.getAsset(baseResource, url, null);
 
             String assetURL = asset.toClientURL();
+
+            String queryParameters = matcher.group(3);
+            if (queryParameters != null) {
+                assetURL += queryParameters;
+            }
+
             appendReplacement(matcher, output, assetURL);
 
             didReplace = true;

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/31e34098/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 5a1e6a8..4de7e04 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
@@ -57,6 +57,42 @@ body {
 
     }
 
+
+    // See TAP5-2106
+    @Test
+    void query_parameters_in_relative_url_are_maintained() {
+        def input = '''
+body {
+  background: white url("images/back.png?v=1.0.0") 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"
+
+        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?v=1.0.0") attach-x;
+}
+'''
+
+
+    }
+
     @Test
     void unquoted_urls_are_matched() {
         def input = '''


[3/6] git commit: Use a single RE to detect absolute paths and paths starting with a scheme

Posted by hl...@apache.org.
Use a single RE to detect absolute paths and paths starting with a scheme


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/2bb0cd29
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/2bb0cd29
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/2bb0cd29

Branch: refs/heads/master
Commit: 2bb0cd29aae5cea4a32ecb8a2754836bf12924cd
Parents: 9d61731
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:42:39 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:42:39 2013 -0700

----------------------------------------------------------------------
 .../internal/services/assets/CSSURLRewriter.java   |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2bb0cd29/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 ed9d12d..149ae74 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,7 +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*:");
+    // Does it start with a '/' or what looks like a scheme ("http:")?
+    private final Pattern completeURLPattern = Pattern.compile("^/|(\\p{Alpha}\\w*:)");
 
     private final OperationTracker tracker;
 
@@ -127,7 +128,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("/") || urlPrefixPattern.matcher(url).find())
+            if (completeURLPattern.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.


[5/6] git commit: TAP5-2040: Expose system properties inside TapestryAppInitializer, as in 5.3

Posted by hl...@apache.org.
TAP5-2040: Expose system properties inside TapestryAppInitializer, as in 5.3


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/bdfcf9a8
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/bdfcf9a8
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/bdfcf9a8

Branch: refs/heads/master
Commit: bdfcf9a873a95b02a3bb253366797883e5d55a3b
Parents: 0df7e5c
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:59:46 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:59:46 2013 -0700

----------------------------------------------------------------------
 .../java/org/apache/tapestry5/TapestryFilter.java  |   12 ++++---
 .../internal/util/DelegatingSymbolProvider.java    |   24 ++++++++-------
 2 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bdfcf9a8/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java b/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
index ed9795f..178571f 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
@@ -20,6 +20,7 @@ import org.apache.tapestry5.internal.TapestryAppInitializer;
 import org.apache.tapestry5.internal.util.DelegatingSymbolProvider;
 import org.apache.tapestry5.ioc.Registry;
 import org.apache.tapestry5.ioc.def.ModuleDef;
+import org.apache.tapestry5.ioc.internal.services.SystemPropertiesSymbolProvider;
 import org.apache.tapestry5.ioc.services.SymbolProvider;
 import org.apache.tapestry5.services.HttpServletRequestHandler;
 import org.apache.tapestry5.services.ServletApplicationInitializer;
@@ -85,12 +86,13 @@ public class TapestryFilter implements Filter
 
         String filterName = config.getFilterName();
 
-        SymbolProvider contextProvider = new ServletContextSymbolProvider(context);
-        SymbolProvider contextPathProvider = new SingleKeySymbolProvider(SymbolConstants.CONTEXT_PATH, context.getContextPath());
+        SymbolProvider combinedProvider = new DelegatingSymbolProvider(
+                new SystemPropertiesSymbolProvider(),
+                new SingleKeySymbolProvider(SymbolConstants.CONTEXT_PATH, context.getContextPath()),
+                new ServletContextSymbolProvider(context),
+                new SingleKeySymbolProvider(SymbolConstants.EXECUTION_MODE, "production"));
 
-        SymbolProvider combinedProvider = new DelegatingSymbolProvider(contextPathProvider, contextProvider);
-
-        String executionMode = System.getProperty(SymbolConstants.EXECUTION_MODE, "production");
+        String executionMode = combinedProvider.valueForSymbol(SymbolConstants.EXECUTION_MODE);
 
         TapestryAppInitializer appInitializer = new TapestryAppInitializer(logger, combinedProvider,
                 filterName, executionMode);

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bdfcf9a8/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
index d7d6c4e..dd1d89c 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
@@ -1,4 +1,4 @@
-// Copyright 2012 The Apache Software Foundation
+// Copyright 2012-2013 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -17,29 +17,31 @@ package org.apache.tapestry5.internal.util;
 import org.apache.tapestry5.ioc.services.SymbolProvider;
 
 /**
- * Combines two symbol providers.
+ * Combines multiple symbol providers.
  *
  * @since 5.4
  */
 public class DelegatingSymbolProvider implements SymbolProvider
 {
-    private final SymbolProvider primary, secondary;
+    private final SymbolProvider[] providers;
 
-    public DelegatingSymbolProvider(SymbolProvider primary, SymbolProvider secondary)
+    public DelegatingSymbolProvider(SymbolProvider... providers)
     {
-        this.primary = primary;
-        this.secondary = secondary;
+        this.providers = providers;
     }
 
     public String valueForSymbol(String symbolName)
     {
-        String value = primary.valueForSymbol(symbolName);
-
-        if (value == null)
+        for (SymbolProvider p : providers)
         {
-            value = secondary.valueForSymbol(symbolName);
+            String value = p.valueForSymbol(symbolName);
+
+            if (value != null)
+            {
+                return value;
+            }
         }
 
-        return value;
+        return null;
     }
 }


[2/6] git commit: TAP5-2106: Do not attempt to rewrite complete URLs

Posted by hl...@apache.org.
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 = '''


[2/6] git commit: TAP5-2106: Do not attempt to rewrite complete URLs

Posted by hl...@apache.org.
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 = '''


[4/6] git commit: TAP5-2106: Treat VML urls (leading '#') as absolute

Posted by hl...@apache.org.
TAP5-2106: Treat VML urls (leading '#') as absolute


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/0df7e5cc
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/0df7e5cc
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/0df7e5cc

Branch: refs/heads/master
Commit: 0df7e5ccfd72bd4d9a79a84f7136db02dc8c84cf
Parents: 2bb0cd2
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:45:25 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:45:25 2013 -0700

----------------------------------------------------------------------
 .../internal/services/assets/CSSURLRewriter.java   |    2 +-
 .../services/assets/CSSURLRewriterTests.groovy     |   15 ++++++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0df7e5cc/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 149ae74..d3d76d6 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
@@ -48,7 +48,7 @@ public class CSSURLRewriter extends DelegatingSRS
     private final Pattern urlPattern = Pattern.compile("url\\(\\s*(['\"]?)(.+?)(\\?.*)?\\1\\s*\\)", Pattern.MULTILINE);
 
     // Does it start with a '/' or what looks like a scheme ("http:")?
-    private final Pattern completeURLPattern = Pattern.compile("^/|(\\p{Alpha}\\w*:)");
+    private final Pattern completeURLPattern = Pattern.compile("^[#/]|(\\p{Alpha}\\w*:)");
 
     private final OperationTracker tracker;
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0df7e5cc/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 bb9dc68..d62ff4d 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
@@ -79,7 +79,6 @@ body {
 
         replay()
 
-
         def rewriter = new CSSURLRewriter(null, null, assetSource, null)
 
         def output = rewriter.replaceURLs input, resource
@@ -154,6 +153,20 @@ body {
         assertNull rewriter.replaceURLs(input, null)
     }
 
+
+    @Test
+    void vml_urls_are_not_replaced() {
+        def input = '''
+span {
+  behavior: url(#default#VML);
+}
+'''
+
+        def rewriter = new CSSURLRewriter(null, null, null, null)
+
+        assertNull rewriter.replaceURLs(input, null)
+    }
+
     @Test
     void absolute_urls_passed_through_unchanged() {
 


[6/6] git commit: TAP5-2079: Handle incorrect context path properly

Posted by hl...@apache.org.
TAP5-2079: Handle incorrect context path properly


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/56a11481
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/56a11481
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/56a11481

Branch: refs/heads/master
Commit: 56a1148121577af5f9b18f6604e27fdf4fc21960
Parents: bdfcf9a
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 16:12:21 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 16:12:21 2013 -0700

----------------------------------------------------------------------
 .../internal/services/PathConstructorImpl.java     |   18 ++++++++++++++-
 .../services/PathConstructorImplSpec.groovy        |    4 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/56a11481/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
index d1e4f1b..9612cf2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
@@ -1,3 +1,17 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package org.apache.tapestry5.internal.services;
 
 import org.apache.tapestry5.SymbolConstants;
@@ -22,7 +36,9 @@ public class PathConstructorImpl implements PathConstructor
 
         dispatchPrefix = b.toString();
 
-        clientPrefix = contextPath + dispatchPrefix;
+        // If you mis-configure embedded Tomcat, you can get a contextPath of "/" rather than "".
+        // To make things fool proof, we handle that case.
+        clientPrefix = (contextPath.equals("/") ? "" : contextPath) + dispatchPrefix;
     }
 
     public String constructClientPath(String... terms)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/56a11481/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
index 53166cc..466133d 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
@@ -12,7 +12,9 @@ class PathConstructorImplSpec extends Assert {
             ["", "", "/foo/bar", "/foo/bar"],
             ["", "myapp", "/myapp/foo/bar", "/myapp/foo/bar"],
             ["/ctx", "", "/ctx/foo/bar", "/foo/bar"],
-            ["/ctx", "myapp", "/ctx/myapp/foo/bar", "/myapp/foo/bar"]
+            ["/ctx", "myapp", "/ctx/myapp/foo/bar", "/myapp/foo/bar"],
+            // TAP5-2079
+            ["/", "myapp", "/myapp/foo/bar", "/myapp/foo/bar"]
         ] as Object[][]
     }
 


[6/6] git commit: TAP5-2079: Handle incorrect context path properly

Posted by hl...@apache.org.
TAP5-2079: Handle incorrect context path properly


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/56a11481
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/56a11481
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/56a11481

Branch: refs/heads/master
Commit: 56a1148121577af5f9b18f6604e27fdf4fc21960
Parents: bdfcf9a
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 16:12:21 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 16:12:21 2013 -0700

----------------------------------------------------------------------
 .../internal/services/PathConstructorImpl.java     |   18 ++++++++++++++-
 .../services/PathConstructorImplSpec.groovy        |    4 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/56a11481/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
index d1e4f1b..9612cf2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
@@ -1,3 +1,17 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package org.apache.tapestry5.internal.services;
 
 import org.apache.tapestry5.SymbolConstants;
@@ -22,7 +36,9 @@ public class PathConstructorImpl implements PathConstructor
 
         dispatchPrefix = b.toString();
 
-        clientPrefix = contextPath + dispatchPrefix;
+        // If you mis-configure embedded Tomcat, you can get a contextPath of "/" rather than "".
+        // To make things fool proof, we handle that case.
+        clientPrefix = (contextPath.equals("/") ? "" : contextPath) + dispatchPrefix;
     }
 
     public String constructClientPath(String... terms)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/56a11481/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
index 53166cc..466133d 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
@@ -12,7 +12,9 @@ class PathConstructorImplSpec extends Assert {
             ["", "", "/foo/bar", "/foo/bar"],
             ["", "myapp", "/myapp/foo/bar", "/myapp/foo/bar"],
             ["/ctx", "", "/ctx/foo/bar", "/foo/bar"],
-            ["/ctx", "myapp", "/ctx/myapp/foo/bar", "/myapp/foo/bar"]
+            ["/ctx", "myapp", "/ctx/myapp/foo/bar", "/myapp/foo/bar"],
+            // TAP5-2079
+            ["/", "myapp", "/myapp/foo/bar", "/myapp/foo/bar"]
         ] as Object[][]
     }
 


[4/6] git commit: TAP5-2106: Treat VML urls (leading '#') as absolute

Posted by hl...@apache.org.
TAP5-2106: Treat VML urls (leading '#') as absolute


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/0df7e5cc
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/0df7e5cc
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/0df7e5cc

Branch: refs/heads/master
Commit: 0df7e5ccfd72bd4d9a79a84f7136db02dc8c84cf
Parents: 2bb0cd2
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:45:25 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:45:25 2013 -0700

----------------------------------------------------------------------
 .../internal/services/assets/CSSURLRewriter.java   |    2 +-
 .../services/assets/CSSURLRewriterTests.groovy     |   15 ++++++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0df7e5cc/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 149ae74..d3d76d6 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
@@ -48,7 +48,7 @@ public class CSSURLRewriter extends DelegatingSRS
     private final Pattern urlPattern = Pattern.compile("url\\(\\s*(['\"]?)(.+?)(\\?.*)?\\1\\s*\\)", Pattern.MULTILINE);
 
     // Does it start with a '/' or what looks like a scheme ("http:")?
-    private final Pattern completeURLPattern = Pattern.compile("^/|(\\p{Alpha}\\w*:)");
+    private final Pattern completeURLPattern = Pattern.compile("^[#/]|(\\p{Alpha}\\w*:)");
 
     private final OperationTracker tracker;
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0df7e5cc/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 bb9dc68..d62ff4d 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
@@ -79,7 +79,6 @@ body {
 
         replay()
 
-
         def rewriter = new CSSURLRewriter(null, null, assetSource, null)
 
         def output = rewriter.replaceURLs input, resource
@@ -154,6 +153,20 @@ body {
         assertNull rewriter.replaceURLs(input, null)
     }
 
+
+    @Test
+    void vml_urls_are_not_replaced() {
+        def input = '''
+span {
+  behavior: url(#default#VML);
+}
+'''
+
+        def rewriter = new CSSURLRewriter(null, null, null, null)
+
+        assertNull rewriter.replaceURLs(input, null)
+    }
+
     @Test
     void absolute_urls_passed_through_unchanged() {
 


[5/6] git commit: TAP5-2040: Expose system properties inside TapestryAppInitializer, as in 5.3

Posted by hl...@apache.org.
TAP5-2040: Expose system properties inside TapestryAppInitializer, as in 5.3


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/bdfcf9a8
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/bdfcf9a8
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/bdfcf9a8

Branch: refs/heads/master
Commit: bdfcf9a873a95b02a3bb253366797883e5d55a3b
Parents: 0df7e5c
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:59:46 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:59:46 2013 -0700

----------------------------------------------------------------------
 .../java/org/apache/tapestry5/TapestryFilter.java  |   12 ++++---
 .../internal/util/DelegatingSymbolProvider.java    |   24 ++++++++-------
 2 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bdfcf9a8/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java b/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
index ed9795f..178571f 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/TapestryFilter.java
@@ -20,6 +20,7 @@ import org.apache.tapestry5.internal.TapestryAppInitializer;
 import org.apache.tapestry5.internal.util.DelegatingSymbolProvider;
 import org.apache.tapestry5.ioc.Registry;
 import org.apache.tapestry5.ioc.def.ModuleDef;
+import org.apache.tapestry5.ioc.internal.services.SystemPropertiesSymbolProvider;
 import org.apache.tapestry5.ioc.services.SymbolProvider;
 import org.apache.tapestry5.services.HttpServletRequestHandler;
 import org.apache.tapestry5.services.ServletApplicationInitializer;
@@ -85,12 +86,13 @@ public class TapestryFilter implements Filter
 
         String filterName = config.getFilterName();
 
-        SymbolProvider contextProvider = new ServletContextSymbolProvider(context);
-        SymbolProvider contextPathProvider = new SingleKeySymbolProvider(SymbolConstants.CONTEXT_PATH, context.getContextPath());
+        SymbolProvider combinedProvider = new DelegatingSymbolProvider(
+                new SystemPropertiesSymbolProvider(),
+                new SingleKeySymbolProvider(SymbolConstants.CONTEXT_PATH, context.getContextPath()),
+                new ServletContextSymbolProvider(context),
+                new SingleKeySymbolProvider(SymbolConstants.EXECUTION_MODE, "production"));
 
-        SymbolProvider combinedProvider = new DelegatingSymbolProvider(contextPathProvider, contextProvider);
-
-        String executionMode = System.getProperty(SymbolConstants.EXECUTION_MODE, "production");
+        String executionMode = combinedProvider.valueForSymbol(SymbolConstants.EXECUTION_MODE);
 
         TapestryAppInitializer appInitializer = new TapestryAppInitializer(logger, combinedProvider,
                 filterName, executionMode);

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bdfcf9a8/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
index d7d6c4e..dd1d89c 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/util/DelegatingSymbolProvider.java
@@ -1,4 +1,4 @@
-// Copyright 2012 The Apache Software Foundation
+// Copyright 2012-2013 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -17,29 +17,31 @@ package org.apache.tapestry5.internal.util;
 import org.apache.tapestry5.ioc.services.SymbolProvider;
 
 /**
- * Combines two symbol providers.
+ * Combines multiple symbol providers.
  *
  * @since 5.4
  */
 public class DelegatingSymbolProvider implements SymbolProvider
 {
-    private final SymbolProvider primary, secondary;
+    private final SymbolProvider[] providers;
 
-    public DelegatingSymbolProvider(SymbolProvider primary, SymbolProvider secondary)
+    public DelegatingSymbolProvider(SymbolProvider... providers)
     {
-        this.primary = primary;
-        this.secondary = secondary;
+        this.providers = providers;
     }
 
     public String valueForSymbol(String symbolName)
     {
-        String value = primary.valueForSymbol(symbolName);
-
-        if (value == null)
+        for (SymbolProvider p : providers)
         {
-            value = secondary.valueForSymbol(symbolName);
+            String value = p.valueForSymbol(symbolName);
+
+            if (value != null)
+            {
+                return value;
+            }
         }
 
-        return value;
+        return null;
     }
 }


[3/6] git commit: Use a single RE to detect absolute paths and paths starting with a scheme

Posted by hl...@apache.org.
Use a single RE to detect absolute paths and paths starting with a scheme


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/2bb0cd29
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/2bb0cd29
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/2bb0cd29

Branch: refs/heads/master
Commit: 2bb0cd29aae5cea4a32ecb8a2754836bf12924cd
Parents: 9d61731
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:42:39 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:42:39 2013 -0700

----------------------------------------------------------------------
 .../internal/services/assets/CSSURLRewriter.java   |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2bb0cd29/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 ed9d12d..149ae74 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,7 +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*:");
+    // Does it start with a '/' or what looks like a scheme ("http:")?
+    private final Pattern completeURLPattern = Pattern.compile("^/|(\\p{Alpha}\\w*:)");
 
     private final OperationTracker tracker;
 
@@ -127,7 +128,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("/") || urlPrefixPattern.matcher(url).find())
+            if (completeURLPattern.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.