You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2014/04/01 18:29:12 UTC
git commit: TAP5-2128: @Import leads to
StringIndexOutOfBoundsException
Repository: tapestry-5
Updated Branches:
refs/heads/master e8ca15f1b -> 91e851364
TAP5-2128: @Import leads to StringIndexOutOfBoundsException
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/91e85136
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/91e85136
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/91e85136
Branch: refs/heads/master
Commit: 91e8513644271bf381ee13fe02f9a0c59217a630
Parents: e8ca15f
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Apr 1 09:29:05 2014 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Apr 1 09:29:05 2014 -0700
----------------------------------------------------------------------
.../ClasspathAssetAliasManagerImpl.java | 9 +++++-
.../apache/tapestry5/services/AssetAlias.java | 4 +--
.../ClasspathAssetAliasManagerImplTest.java | 29 ++++++++++++++++++--
3 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/91e85136/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImpl.java
index 9c14d6a..6b6f1e2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImpl.java
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2009, 2011, 2013 The Apache Software Foundation
+// Copyright 2006-2014 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.
@@ -87,6 +87,13 @@ public class ClasspathAssetAliasManagerImpl implements ClasspathAssetAliasManage
{
if (resourcePath.startsWith(pathPrefix))
{
+ if (pathPrefix.length() == resourcePath.length())
+ {
+ throw new IllegalArgumentException(String.format("Resource path '%s' is not valid as it is mapped as virtual folder '%s'.",
+ resourcePath,
+ pathPrefixToAlias.get(pathPrefix)));
+ }
+
// Prevent matching path prefix "foo" against "foobar" ... it must match against "foo/".
if (resourcePath.charAt(pathPrefix.length()) != '/')
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/91e85136/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetAlias.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetAlias.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetAlias.java
index 15ee1b7..5edd069 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetAlias.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/AssetAlias.java
@@ -1,4 +1,4 @@
-// Copyright 2013 The Apache Software Foundation
+// Copyright 2013-2014 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.
@@ -15,7 +15,7 @@
package org.apache.tapestry5.services;
/**
- * Identifies a virtual foldre and a path within that folder.
+ * Identifies a virtual folder and a path within that folder.
*
* @since 5.4
* @deprecated Deprecated in 5.4 (see notes in {@link ClasspathAssetAliasManager}).
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/91e85136/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImplTest.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImplTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImplTest.java
index fcff983..2995d42 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImplTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImplTest.java
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2009, 2010, 2011, 2012, 2013 The Apache Software Foundation
+// Copyright 2006-2014 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.
@@ -93,6 +93,31 @@ public class ClasspathAssetAliasManagerImplTest extends InternalBaseTestCase
}
@Test
+ public void can_not_map_resource_path_that_matches_virtual_folder() throws IOException
+ {
+ Resource r = mockResource();
+
+ expect(r.getPath()).andReturn("com/example/mylib");
+
+ replay();
+
+ ClasspathAssetAliasManager manager = new ClasspathAssetAliasManagerImpl(configuration());
+
+ try
+ {
+ manager.extractAssetAlias(r);
+
+ unreachable();
+ } catch (IllegalArgumentException ex)
+ {
+
+ }
+
+ verify();
+
+ }
+
+ @Test
public void failure_if_path_not_in_mapped_alias_folder()
{
ClasspathAssetAliasManager manager = new ClasspathAssetAliasManagerImpl(configuration());
@@ -125,7 +150,7 @@ public class ClasspathAssetAliasManagerImplTest extends InternalBaseTestCase
{"com/example/mylib/Foo.bar", "mylib", "Foo.bar"},
{"com/example/mylib/nested/Foo.bar", "mylib", "nested/Foo.bar"},
{"org/apache/tapestry5/internal/Foo.bar", "tapestry-internal", "Foo.bar"},
- {"org/apache/tapestry5/Foo.bar", "tapestry", "Foo.bar"}
+ {"org/apache/tapestry5/Foo.bar", "tapestry", "Foo.bar"},
};
}