adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
723 stars 737 forks source link

Incorrect filename when downloading asset embedded within Download component #2748

Open HitmanInWis opened 1 month ago

HitmanInWis commented 1 month ago

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(), '/');