Skip to content

Commit

Permalink
apoc.load procedures don't work anymore with urls containing %
Browse files Browse the repository at this point in the history
Fixes #2269
  • Loading branch information
vga91 authored Apr 7, 2022
1 parent 08bb064 commit b6e3c7f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions core/src/main/java/apoc/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import apoc.util.s3.S3URLConnection;
import apoc.util.s3.S3UploadUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.output.WriterOutputStream;
import org.apache.commons.lang3.StringUtils;
import org.neo4j.configuration.GraphDatabaseSettings;

Expand All @@ -32,7 +31,6 @@
import static apoc.ApocConfig.apocConfig;
import static apoc.util.Util.ERROR_BYTES_OR_STRING;
import static apoc.util.Util.readHttpInputStream;
import static org.eclipse.jetty.util.URIUtil.encodePath;

/**
* @author mh
Expand Down Expand Up @@ -174,13 +172,12 @@ public static CountingInputStream inputStreamFor(String fileName) throws IOExcep
return inputStreamFor(fileName, null, null, CompressionAlgo.NONE.name());
}

public static String changeFileUrlIfImportDirectoryConstrained(String urlNotEncoded) throws IOException {
final String url = encodeExceptQM(urlNotEncoded);
public static String changeFileUrlIfImportDirectoryConstrained(String url) throws IOException {
if (isFile(url) && isImportUsingNeo4jConfig()) {
if (!apocConfig().getBoolean(APOC_IMPORT_FILE_ALLOW__READ__FROM__FILESYSTEM)) {
throw new RuntimeException(String.format(ERROR_READ_FROM_FS_NOT_ALLOWED, url));
}
final Path resolvedPath = resolvePath(urlNotEncoded);
final Path resolvedPath = resolvePath(url);
return resolvedPath
.normalize()
.toUri()
Expand Down Expand Up @@ -353,11 +350,6 @@ public static Path getPathFromUrlString(String urlDir) {
return Paths.get(URI.create(urlDir));
}

// to exclude cases like 'testload.tar.gz?raw=true'
private static String encodeExceptQM(String url) {
return encodePath(url).replace("%3F", "?");
}

public static CountingInputStream getInputStreamFromBinary(byte[] urlOrBinary, String compressionAlgo) {
return CompressionAlgo.valueOf(compressionAlgo).toInputStream(urlOrBinary);
}
Expand Down

0 comments on commit b6e3c7f

Please sign in to comment.