You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by th...@apache.org on 2020/07/26 19:09:41 UTC

[tapestry-5] branch java9modules updated: TAP5-2632: slashes in context URLs are not handled properly

This is an automated email from the ASF dual-hosted git repository.

thiagohp pushed a commit to branch java9modules
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git


The following commit(s) were added to refs/heads/java9modules by this push:
     new 13cdf04  TAP5-2632: slashes in context URLs are not handled properly
13cdf04 is described below

commit 13cdf04f63aec8cba9ac29858f2e1d72c3949263
Author: Thiago H. de Paula Figueiredo <th...@arsmachina.com.br>
AuthorDate: Sun Jul 26 16:07:28 2020 -0300

    TAP5-2632: slashes in context URLs are not handled properly
---
 .../internal/services/assets/ChecksumPath.java         | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/ChecksumPath.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/ChecksumPath.java
index 074fd86..7e5f95e 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/ChecksumPath.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/ChecksumPath.java
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry5.internal.services.assets;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.tapestry5.internal.services.ResourceStreamer;
 import org.apache.tapestry5.ioc.Resource;
 
@@ -27,6 +28,8 @@ import java.io.IOException;
  */
 public class ChecksumPath
 {
+    private static final String NON_EXISTING_RESOURCE = "_________________________";
+
     public final String checksum;
 
     public final String resourcePath;
@@ -38,13 +41,20 @@ public class ChecksumPath
         this.streamer = streamer;
         int slashx = extraPath.indexOf('/');
 
-        checksum = extraPath.substring(0, slashx);
+        checksum = slashx >= 0 ? extraPath.substring(0, slashx) : null;
 
         String morePath = extraPath.substring(slashx + 1);
 
-        resourcePath = baseFolder == null
-                ? morePath
-                : baseFolder + "/" + morePath;
+        if (StringUtils.isNotBlank(morePath)) {
+            resourcePath = baseFolder == null
+                    ? morePath
+                    : baseFolder + "/" + morePath;
+        }
+        else {
+            // When we only have something which looks like a checksum but no actual path.
+            // For example, /assets/META-INF/
+            resourcePath = NON_EXISTING_RESOURCE;
+        }
     }
 
     /**