Skip to content

Commit c951b1c

Browse files
committed
update for reading configuration from file path with spaces
1 parent e179580 commit c951b1c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/main/java/org/owasp/esapi/reference/DefaultSecurityConfiguration.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.FileNotFoundException;
2121
import java.io.IOException;
2222
import java.io.InputStream;
23+
import java.net.URISyntaxException;
2324
import java.net.URL;
2425
import java.util.ArrayList;
2526
import java.util.Arrays;
@@ -581,13 +582,17 @@ public File getResourceFile(String filename) {
581582
}
582583

583584
if (fileUrl != null) {
584-
String fileLocation = fileUrl.getFile();
585-
f = new File(fileLocation);
586-
if (f.exists()) {
587-
logSpecial("Found in SystemResource Directory/resourceDirectory: " + f.getAbsolutePath());
588-
return f;
589-
} else {
590-
logSpecial("Not found in SystemResource Directory/resourceDirectory (this should never happen): " + f.getAbsolutePath());
585+
try {
586+
String fileLocation = fileUrl.toURI().getPath();
587+
f = new File(fileLocation);
588+
if (f.exists()) {
589+
logSpecial("Found in SystemResource Directory/resourceDirectory: " + f.getAbsolutePath());
590+
return f;
591+
} else {
592+
logSpecial("Not found in SystemResource Directory/resourceDirectory (this should never happen): " + f.getAbsolutePath());
593+
}
594+
} catch (URISyntaxException e) {
595+
logSpecial("Error while converting URL " + fileUrl + " to file path: " + e.getMessage());
591596
}
592597
} else {
593598
logSpecial("Not found in SystemResource Directory/resourceDirectory: " + resourceDirectory + File.separator + filename);

0 commit comments

Comments
 (0)