You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Upload some file with the name John Doe (Test) 2021 01.jpg and regarding upload access conditions.
Save the document and wait for the thumbnail to be created or manually create the thumbnail using the filter-media process
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.
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
The text was updated successfully, but these errors were encountered:
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:
John Doe (Test) 2021 01.jpg
and regarding upload access conditions.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
The text was updated successfully, but these errors were encountered: