[MGNLDAM-445] Uploaded assets are not given a web-safe filename; are unreachable Created: 14/May/14  Updated: 18/Sep/14  Resolved: 17/Jul/14

Status: Closed
Project: Magnolia DAM Module
Component/s: DAM Core, User Interaction
Affects Version/s: 1.0
Fix Version/s: 1.2.6, 2.0.2

Type: Bug Priority: Major
Reporter: Rory Gibson Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: dam
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
is duplicated by MGNLDAM-487 Documents with national characters in... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

If you upload any file to Assets via the admin site, without a web-safe filename – that is, anything that falls foul of regex /[0-9A-Za-z_-]+/ – the system will attempt to convert the filename for you but silently fails to actually do so, even though the displayed filename appears to conform to the rule above.

However, you cannot be served the file via the public site via the DAM as it will fail to be found (404).

If you click the Rename Asset link (with the file selected) you will note it still has the original unsafe filename.

The temporary workaround we're using for this is as follows:

If the asset has already been uploaded:
• Click Rename Asset and give it a web-safe filename.
• Click Edit Asset and give it the same web-safe filename in the Media > Name field (yes, you must to both these renaming actions in this order).
• Publish.

If the asset has not yet been uploaded:
• Upload the asset but change the filename to a safe one in the Media > Name field before saving changes.
• Publish the asset.

========

Steps to reproduce on the demo site http://demo.magnolia-cms.com as follows:
• Go to the Assets page.
• Into demo-project/downloads, upload any random file whose name is valid, eg "this-is-ok.txt".
• Publish the asset.
• Confirm you're offered the file for download via the public url, eg: http://demo.magnolia-cms.com/dam/demo-project/downloads/this-is-ok.txt

• Now upload another file whose name is invalid, eg "spaces in this name.txt".
• Publish the asset.
• Confirm you CANNOT reach the file for download via the public url, eg: http://demo.magnolia-cms.com/dam/demo-project/downloads/spaces%20in%20this%20name.txt

• Now click [Edit Asset] and give it a safe name, eg "no-spaces-in-this-name", and click [Save Changes].
• Notice the Asset Name in the list/tree view of Assets has NOT changed.
• Click [Rename Asset], notice the Name is actually correct, and click [Save Changes] without doing anything else.
• Notice the Asset Name in the list/tree view of Assets has changed to the new value.
• Publish the asset.
• Confirm you're now offered the file for download via the public url, eg: http://demo.magnolia-cms.com/dam/demo-project/downloads/no-spaces-in-this-name.txt

========

Issues possiblly related?
https://jira.magnolia-cms.com/browse/MGNLFORM-208
https://jira.magnolia-cms.com/browse/MGNLDAM-310
https://jira.magnolia-cms.com/browse/MGNLDAM-423



 Comments   
Comment by Peter Phillips [ 15/May/14 ]

If Magnolia detects that the filename is unsafe, it appears to create an extra section to the filename including the sanitised filename in the path of the download. I'm guessing that if the sanitised filename is the same as the actual one then this step is then missed out, hence guessing the URL by adding /dam/ and the filename extension then works.

Hence "spaces in this name.txt" is actually then available under http://demo.magnolia-cms.com/demo-project/dam/demo-project/downloads/spaces-in-this-name/spaces%20in%20this%20name.txt instead. Unfortunately due to there being no download link on the asset page (https://jira.magnolia-cms.com/browse/MGNLDAM-423) this is not obvious. The only way to find out the true URL for the download link is then to add a link to the asset to a page and then look at the resulting link when previewing the page.

I've tried on the demo site and been able to upload the "spaces in this name.txt" asset and then download it successfully after adding it as a link on a page to get the URL. Therefore I think that altough the uploaded assets are not given a web-safe filename, they are still reachable and can be downloaded okay.

Comment by Eric Hechinger [ 17/Jul/14 ]

I did the following test:

  • Upload in DAM two new assets under /demo-project/downloads/ with the following filename:
    • images copy of you.jpg
    • výkazy.pdf
  • Publish them
  • From the public instance the download is correctly working :
    • for DAM 1.2.6
      ../magnoliaPublic/dam/demo-project/downloads/images-copy-of-tutu/images copy of you.jpg
      ../magnoliaPublic/dam/demo-project/downloads/vy-kazy/výkazy.pdf
    • for DAM 2.0.2 (we do not use any more the path but rather the Asset ItemKey)
      ../dam/jcr:80032d62-9105-4b62-86e2-add989dbb1a5/výkazy.pdf
      this would also work (dam/jcr:80032d62-9105-4b62-86e2-add989dbb1a5)
      ../dam/jcr:75a1771f-f50f-4e5a-bce8-a325406ee198/images copy of you.jpg

Will close the issue.

Generated at Mon Feb 12 04:59:54 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.