File tree Expand file tree Collapse file tree
dspace-server-webapp/src/test/java/org/dspace/app/sword2
dspace-swordv2/src/main/java/org/dspace/sword2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -258,7 +258,8 @@ public void depositAndEditViaSwordTest() throws Exception {
258258 // Add required headers
259259 HttpHeaders headers = new HttpHeaders ();
260260 headers .setContentType (MediaType .MULTIPART_FORM_DATA );
261- headers .setContentDisposition (ContentDisposition .attachment ().filename ("example.zip" ).build ());
261+ // Test the file with spaces or special characters in the name
262+ headers .setContentDisposition (ContentDisposition .attachment ().filename ("example .zip" ).build ());
262263 headers .set ("Packaging" , "http://purl.org/net/sword/package/METSDSpaceSIP" );
263264 headers .setAccept (List .of (MediaType .APPLICATION_ATOM_XML ));
264265
Original file line number Diff line number Diff line change 77 */
88package org .dspace .sword2 ;
99
10+ import java .net .URLEncoder ;
11+ import java .nio .charset .StandardCharsets ;
1012import java .sql .SQLException ;
1113import java .util .List ;
1214
@@ -386,10 +388,10 @@ public String getBitstreamUrl(Bitstream bitstream)
386388
387389 if (handle != null && !"" .equals (handle )) {
388390 bsLink = bsLink + "/bitstream/" + handle + "/" +
389- bitstream .getSequenceID () + "/" + bitstream .getName ();
391+ bitstream .getSequenceID () + "/" + URLEncoder . encode ( bitstream .getName (), StandardCharsets . UTF_8 );
390392 } else {
391393 bsLink = bsLink + "/retrieve/" + bitstream .getID () + "/" +
392- bitstream .getName ();
394+ URLEncoder . encode ( bitstream .getName (), StandardCharsets . UTF_8 );
393395 }
394396
395397 return bsLink ;
@@ -401,7 +403,7 @@ public String getBitstreamUrl(Bitstream bitstream)
401403 public String getActionableBitstreamUrl (Bitstream bitstream )
402404 throws DSpaceSwordException {
403405 return this .getSwordBaseUrl () + "/edit-media/bitstream/" +
404- bitstream .getID () + "/" + bitstream .getName ();
406+ bitstream .getID () + "/" + URLEncoder . encode ( bitstream .getName (), StandardCharsets . UTF_8 );
405407 }
406408
407409 public boolean isActionableBitstreamUrl (Context context , String url ) {
You can’t perform that action at this time.
0 commit comments