Skip to content

Commit

Permalink
Merge pull request #13409 from iterate-ch/bugfix/GH-13407
Browse files Browse the repository at this point in the history
Review URI encoding of key
  • Loading branch information
dkocher authored Nov 11, 2024
2 parents dbb3fe5 + 4bda72c commit 63953d1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions core/src/test/java/ch/cyberduck/core/URIEncoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ public void testEncodeRelativeUri() {
assertEquals("a/p", URIEncoder.encode("a/p"));
assertEquals("a/p/", URIEncoder.encode("a/p/"));
}

@Test
public void testEncodeEmoji() {
assertEquals("a/%F0%9F%9A%80", URIEncoder.encode("a/\uD83D\uDE80"));
assertEquals("a/\uD83D\uDE80", URIEncoder.decode("a/%F0%9F%9A%80"));
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<dependency>
<groupId>ch.iterate.s3</groupId>
<artifactId>jets3t</artifactId>
<version>0.9.36</version>
<version>0.9.37</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ch.cyberduck.core.PathNormalizer;
import ch.cyberduck.core.PreferencesUseragentProvider;
import ch.cyberduck.core.Scheme;
import ch.cyberduck.core.URIEncoder;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.features.Location;
import ch.cyberduck.core.preferences.HostPreferences;
Expand Down Expand Up @@ -53,7 +54,6 @@
import org.jets3t.service.model.StorageBucketLoggingStatus;
import org.jets3t.service.model.StorageObject;
import org.jets3t.service.model.WebsiteConfig;
import org.jets3t.service.utils.RestUtils;
import org.jets3t.service.utils.ServiceUtils;

import java.util.Calendar;
Expand Down Expand Up @@ -222,7 +222,7 @@ public HttpUriRequest setupConnection(final HTTP_METHOD method, final String buc
virtualPath = StringUtils.EMPTY;
}
if(objectKey != null) {
resource += RestUtils.encodeUrlPath(objectKey, "/");
resource += URIEncoder.encode(objectKey);
}
// Construct a URL representing a connection for the S3 resource.
String url;
Expand Down
12 changes: 12 additions & 0 deletions s3/src/test/java/ch/cyberduck/core/s3/S3ReadFeatureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.cyberduck.core.AlphanumericRandomStringService;
import ch.cyberduck.core.BytecountStreamListener;
import ch.cyberduck.core.DisabledConnectionCallback;
import ch.cyberduck.core.DisabledListProgressListener;
import ch.cyberduck.core.DisabledLoginCallback;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.exception.NotfoundException;
Expand Down Expand Up @@ -64,6 +65,17 @@ public void testReadRange() throws Exception {
new S3DefaultDeleteFeature(session, new S3AccessControlListFeature(session)).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

@Test
public void testReadEmoji() throws Exception {
final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path test = new S3TouchFeature(session, new S3AccessControlListFeature(session)).touch(
new Path(container, String.format("%s-\uD83D\uDE80", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file)), new TransferStatus());
assertTrue(new S3ListService(session, new S3AccessControlListFeature(session)).list(container, new DisabledListProgressListener()).contains(test));
final InputStream in = new S3ReadFeature(session).read(test, new TransferStatus().withLength(0L), new DisabledConnectionCallback());
in.close();
new S3DefaultDeleteFeature(session, new S3AccessControlListFeature(session)).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

@Test
public void testReadRangeUnknownLength() throws Exception {
final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
Expand Down

0 comments on commit 63953d1

Please sign in to comment.