Solved WW-3309 - used FileUtils to decode URLs and XW-378 - upgraded OGNL to version 3.0

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@941352 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2010-05-05 15:35:52 +00:00
parent e04cbca2a1
commit c7757ae1ef
2 changed files with 33 additions and 10 deletions
+25 -1
View File
@@ -25,7 +25,7 @@
<currentVersion>${pom.version}</currentVersion>
<struts2.springPlatformVersion>2.5.6</struts2.springPlatformVersion>
<asm.version>3.1</asm.version>
<ognl.version>2.7.3</ognl.version>
<ognl.version>3.0</ognl.version>
</properties>
<profiles>
@@ -199,6 +199,10 @@
<include>org/apache/commons/lang/UnhandledException.class</include>
<include>org/apache/commons/lang/IntHashMap*class</include>
</includes>
<artifact>commons-io:commons-io</artifact>
<includes>
<include>org/apache/commons/io/FileUtils.class</include>
</includes>
</filter>
</filters>
<relocations>
@@ -210,6 +214,10 @@
<pattern>org.apache.commons.lang</pattern>
<shadedPattern>org.apache.commons.lang.xwork</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.lang</pattern>
<shadedPattern>org.apache.commons.io.xwork</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer
@@ -219,6 +227,7 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@@ -254,6 +263,12 @@
<version>2.4</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
@@ -317,6 +332,7 @@
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${struts2.springPlatformVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -352,6 +368,14 @@
<version>2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.10.0.GA</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -17,6 +17,7 @@ package com.opensymphony.xwork2.util;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
@@ -279,16 +280,13 @@ public class FileManager {
entry = null;
}
if (entry != null) {
return (this.lastModified < entry.getTime());
} else {
return false;
}
return entry != null && (lastModified < entry.getTime());
}
public static Revision build(URL fileUrl) {
// File within a Jar
// Find separator index of jar filename and filename within jar
String jarFileName = "";
try {
String fileName = fileUrl.toString();
int separatorIndex = fileName.indexOf(JAR_FILE_NAME_SEPARATOR);
@@ -300,19 +298,20 @@ public class FileManager {
return null;
}
// Split file name
String jarFileName = fileName.substring(0, separatorIndex);
String fileNameInJar = fileName.substring(separatorIndex + JAR_FILE_NAME_SEPARATOR.length()).replaceAll("%20", " ");
jarFileName = fileName.substring(0, separatorIndex);
int index = separatorIndex + JAR_FILE_NAME_SEPARATOR.length();
String fileNameInJar = fileName.substring(index).replaceAll("%20", " ");
URL url = URLUtil.normalizeToFileProtocol(fileUrl);
if (url != null) {
JarFile jarFile = new JarFile(new File(url.getPath().replaceAll("%20", " ")));
JarFile jarFile = new JarFile(FileUtils.toFile(url));
ZipEntry entry = jarFile.getEntry(fileNameInJar);
return new JarEntryRevision(jarFileName.toString(), fileNameInJar, entry.getTime());
} else {
return null;
}
} catch (Throwable e) {
LOG.warn("Could not create JarEntryRevision!", e);
LOG.warn("Could not create JarEntryRevision for [" + jarFileName + "]!", e);
return null;
}
}