if( this.getLogger().isDebugEnabled() ) {
this.getLogger().debug( "Creating source object for " + location );
}
// Lookup resolver
SourceResolver resolver = null;
try {
resolver = (SourceResolver)this.manager.lookup( SourceResolver.ROLE );
// Remove the protocol and the first '/'
final int pos = location.indexOf(":/");
final String path = location.substring(pos+1);
// fix for #24093, we don't give access to files outside the context:
if ( path.indexOf("../") != -1 ) {
throw new MalformedURLException("Invalid path ('../' is not allowed) : " + path);
}
URL u;
// Try to get a file first and fall back to a resource URL
String actualPath = envContext.getRealPath(path);
if (actualPath != null) {
u = new File(actualPath).toURL();
} else {
u = envContext.getResource(path);
}
if (u != null) {
return resolver.resolveURI(u.toExternalForm());
} else {
String message = location + " could not be found. (possible context problem)";
getLogger().info(message);
throw new MalformedURLException(message);