Skip to content

Commit

Permalink
Merge pull request #21 from Coreoz/fix/fragment-escaper-method
Browse files Browse the repository at this point in the history
fix fragment escaper method
  • Loading branch information
amanteaux authored Jan 22, 2024
2 parents 4041977 + 3978cec commit e16ea1e
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.coreoz.plume.file.cleaning.FileExtensionCleaning;
import com.coreoz.plume.file.cleaning.FileNameCleaning;
import com.coreoz.plume.jersey.security.permission.PublicApi;
import com.google.common.net.UrlEscapers;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -21,8 +22,6 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.Optional;

Expand Down Expand Up @@ -100,8 +99,7 @@ public Response fetch(
if (attachment) {
String attachmentFilename = Optional.ofNullable(fileMetadata.getFileOriginalName())
.orElse(fileMetadata.getUniqueName());
String utf8FileName = URLEncoder.encode(attachmentFilename, StandardCharsets.UTF_8)
.replace("+", "%20");
String utf8FileName = UrlEscapers.urlFragmentEscaper().escape(attachmentFilename);
String sanitizedFileName = FileNameCleaning.cleanFileName(attachmentFilename);
response
.header(
Expand Down

0 comments on commit e16ea1e

Please sign in to comment.