aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-03-26 13:51:26 +0100
committerJiri Vanek <[email protected]>2013-03-26 13:51:26 +0100
commitc4f2dc4c8dc8c025c5d27c627717a164755986ae (patch)
treebe59c44f693ada0cb59fde526fcf7c34dbe66da0 /netx/net/sourceforge/jnlp
parentae6c64c61189a845f989c3b968a285b1029e5709 (diff)
Path validator fixed to be correctly multiplatform
Diffstat (limited to 'netx/net/sourceforge/jnlp')
-rw-r--r--netx/net/sourceforge/jnlp/config/BasicValueValidators.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/netx/net/sourceforge/jnlp/config/BasicValueValidators.java b/netx/net/sourceforge/jnlp/config/BasicValueValidators.java
index 1cb2af7..f4e8a65 100644
--- a/netx/net/sourceforge/jnlp/config/BasicValueValidators.java
+++ b/netx/net/sourceforge/jnlp/config/BasicValueValidators.java
@@ -37,6 +37,7 @@ exception statement from your version.
package net.sourceforge.jnlp.config;
+import java.io.File;
import static net.sourceforge.jnlp.runtime.Translator.R;
import java.net.URL;
@@ -86,8 +87,9 @@ public class BasicValueValidators {
* Checks if a value is a valid file path (not a valid file!). The actual
* file may or may not exist
*/
- private static class FilePathValidator implements ValueValidator {
-
+ //package private for testing purposes
+ static class FilePathValidator implements ValueValidator {
+
@Override
public void validate(Object value) throws IllegalArgumentException {
if (value == null) {
@@ -97,13 +99,15 @@ public class BasicValueValidators {
Object possibleValue = value;
if (!(possibleValue instanceof String)) {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Value should be string!");
}
String possibleFile = (String) possibleValue;
- if (!(possibleFile.startsWith("/"))) {
- throw new IllegalArgumentException();
- }
+
+ boolean absolute = new File(possibleFile).isAbsolute();
+ if (!absolute) {
+ throw new IllegalArgumentException("File must be absolute");
+ }
}