aem-core-wcm-components icon indicating copy to clipboard operation
aem-core-wcm-components copied to clipboard

Incorrect filename when downloading asset embedded within Download component

Open HitmanInWis opened this issue 1 year ago • 0 comments

Bug Version: 2.24.7-SNAPSHOT

When downloading a file that is directly uploaded to a Download component, the filename put into the Content-Disposition header is prepended with /, which results in the file being downloaded (at least in Chrome) with a prefixed _ character. i.e. file name uploaded = "myfile.txt", but downloads as "_myfile.txt"

The issue appears to be in com.adobe.cq.wcm.core.components.internal.servlets.DownloadServlet

In the doGet function,

        if (asset == null) {
            String filename = request.getRequestPathInfo().getSuffix();

Should be updated to

        if (asset == null) {
            String filename = StringUtils.removeStart(request.getRequestPathInfo().getSuffix(), '/');

HitmanInWis avatar May 07 '24 21:05 HitmanInWis