kopia lustrzana https://github.com/gaul/s3proxy
uri decode path before passing them to lower layers
rodzic
15e11975a2
commit
b91b8e25d7
|
@ -20,6 +20,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
@ -111,6 +112,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
|||
private final String credential;
|
||||
private final boolean forceMultiPartUpload;
|
||||
private final Optional<String> virtualHost;
|
||||
private final URLDecoder urlDecoder = new URLDecoder();
|
||||
|
||||
S3ProxyHandler(BlobStore blobStore, String identity, String credential,
|
||||
boolean forceMultiPartUpload, Optional<String> virtualHost) {
|
||||
|
@ -262,6 +264,9 @@ final class S3ProxyHandler extends AbstractHandler {
|
|||
}
|
||||
|
||||
String[] path = uri.split("/", 3);
|
||||
for (int i = 0; i < path.length; i++) {
|
||||
path[i] = urlDecoder.decode(path[i], "UTF-8");
|
||||
}
|
||||
switch (method) {
|
||||
case "DELETE":
|
||||
if (path.length <= 2 || path[2].isEmpty()) {
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.jclouds.blobstore.BlobStore;
|
|||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.domain.PageSet;
|
||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -219,6 +220,17 @@ public final class S3ProxyTest {
|
|||
putBlobAndCheckIt("blob%%");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlobEscape() throws Exception {
|
||||
assertThat(s3BlobStore.list(containerName)).isEmpty();
|
||||
putBlobAndCheckIt("blob%");
|
||||
PageSet<? extends StorageMetadata> res =
|
||||
s3BlobStore.list(containerName);
|
||||
StorageMetadata meta = res.iterator().next();
|
||||
assertThat(meta.getName()).isEqualTo("blob%");
|
||||
assertThat(res).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlobList() throws Exception {
|
||||
assertThat(s3BlobStore.list(containerName)).isEmpty();
|
||||
|
|
Ładowanie…
Reference in New Issue