SWF-1388 Move Spring JS resources to META-INF/web-resources
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
<antcall target="minify-spring-js" inheritAll="false"/>
|
||||
|
||||
<unzip src="${basedir}/../spring-js/dojo-build/dojo-build.zip"
|
||||
dest="${main.output.dir}/META-INF"/>
|
||||
dest="${main.output.dir}/META-INF/web-resources"/>
|
||||
|
||||
<jar destfile="${jar.output.file}" basedir="${main.output.dir}" index="true" filesetmanifest="merge">
|
||||
<manifest>
|
||||
@@ -80,8 +80,8 @@
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<compress file="/META-INF/spring/Spring.js"/>
|
||||
<compress file="/META-INF/spring/Spring-Dojo.js"/>
|
||||
<compress file="/META-INF/web-resources/spring/Spring.js"/>
|
||||
<compress file="/META-INF/web-resources/spring/Spring-Dojo.js"/>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ public class ResourceServlet extends HttpServletBean {
|
||||
|
||||
private String jarPathPrefix = "META-INF";
|
||||
|
||||
private String springJsJarPathPrefix = "META-INF/web-resources";
|
||||
|
||||
private boolean gzipEnabled = true;
|
||||
|
||||
private Set allowedResourcePaths = new HashSet();
|
||||
@@ -254,22 +256,10 @@ public class ResourceServlet extends HttpServletBean {
|
||||
}
|
||||
URL resource = getServletContext().getResource(localResourcePath);
|
||||
if (resource == null) {
|
||||
String jarResourcePath = jarPathPrefix + localResourcePath;
|
||||
if (!isAllowed(jarResourcePath)) {
|
||||
if (log.isWarnEnabled()) {
|
||||
log
|
||||
.warn("An attempt to access a protected resource at " + jarResourcePath
|
||||
+ " was disallowed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (jarResourcePath.startsWith("/")) {
|
||||
jarResourcePath = jarResourcePath.substring(1);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Searching classpath for resource: " + jarResourcePath);
|
||||
}
|
||||
resource = ClassUtils.getDefaultClassLoader().getResource(jarResourcePath);
|
||||
resource = getJarResource(springJsJarPathPrefix, localResourcePath);
|
||||
}
|
||||
if (resource == null) {
|
||||
resource = getJarResource(jarPathPrefix, localResourcePath);
|
||||
}
|
||||
if (resource == null) {
|
||||
if (resources.length > 1) {
|
||||
@@ -283,6 +273,23 @@ public class ResourceServlet extends HttpServletBean {
|
||||
return resources;
|
||||
}
|
||||
|
||||
private URL getJarResource(String jarPrefix, String resourcePath) {
|
||||
String jarResourcePath = jarPrefix + resourcePath;
|
||||
if (!isAllowed(jarResourcePath)) {
|
||||
if (log.isWarnEnabled()) {
|
||||
log.warn("An attempt to access a protected resource at " + jarResourcePath + " was disallowed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (jarResourcePath.startsWith("/")) {
|
||||
jarResourcePath = jarResourcePath.substring(1);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Searching classpath for resource: " + jarResourcePath);
|
||||
}
|
||||
return ClassUtils.getDefaultClassLoader().getResource(jarResourcePath);
|
||||
}
|
||||
|
||||
private boolean isAllowed(String resourcePath) {
|
||||
if (resourcePath.matches(protectedPath)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user