Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thumbnail not found when filename contains special characters #9112

Closed
floriangantner opened this issue Oct 10, 2023 · 0 comments · Fixed by #9113
Closed

Thumbnail not found when filename contains special characters #9112

floriangantner opened this issue Oct 10, 2023 · 0 comments · Fixed by #9113
Assignees
Labels
Milestone

Comments

@floriangantner
Copy link
Contributor

floriangantner commented Oct 10, 2023

Describe the bug
The thumbnail of some bitstream will not be loaded when the bitstream file name contains special characters. These characters are considered as part of the regular expression for fetching the thumbnail.
We discovered this behaviour in DSpace-Cris7 , but it should be reproduce-able in normal DSpace installations since the code does not differ.

To Reproduce
Steps to reproduce the behavior:

  1. Upload some file with the name John Doe (Test) 2021 01.jpg and regarding upload access conditions.
  2. Save the document and wait for the thumbnail to be created or manually create the thumbnail using the filter-media process
  3. The thumbnail should be displayed in the bundle/bitstream administration, but the rest api should not deliver the thumbnail.

Expected behavior
We expect the thumbnail to be shown and special characters in filename to be considered.

Example given:
In our opinion the construction of the Pattern is wrong:
https://github.com/DSpace/DSpace/blob/92844f0b05f4a073a96ccd9a7961e234bdb6e8f5/dspace-api/src/main/java/org/dspace/content/BitstreamServiceImpl.java#L406C25-L406C25

Bitstream name:
John Doe (Test) 2021 01.jpg
The regex being created is:
^John Doe (Test) 2021 01.jpg.([^.]+)$
The brackets seem to be interpreted as part of the regex and thus the regex does not match some thumbnail with name
John Doe (Test) 2021 01.jpg.jpg

We suggest some wrapping of Pattern.quote() around the bitstream namer.
Pattern pattern = Pattern.compile("^" + Pattern.quote(bitstream.getName()) + ".([^.]+)$");
This should lead to the regex literally matching the file name
^\QJohn Doe (Test) 2021 01.jpg\E.([^.]+)$
which should match the thumbnail name
John Doe (Test) 2021 01.jpg.jpg
and deliver the correct thumbnail

Related work

@floriangantner floriangantner added bug needs triage New issue needs triage and/or scheduling labels Oct 10, 2023
@tdonohue tdonohue removed the needs triage New issue needs triage and/or scheduling label Oct 10, 2023
@tdonohue tdonohue added this to the 7.6.1 milestone Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants