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

Redirect URLs with spaces in bitstream filename from legacy DSpace results in 404 in D7 #3871

Closed
msarmie opened this issue Jan 21, 2025 · 1 comment
Assignees
Labels
affects: 7.x Issue impacts 7.x releases bug component: SEO Search Engine Optimization
Milestone

Comments

@msarmie
Copy link
Contributor

msarmie commented Jan 21, 2025

Describe the bug

We migrated a DSpace instance from version 6 to version 7.6.2 and discovered that old URLs with spaces in bitstream filenames are not redirecting to the file in the D7 deployment. This issue only occurs in D7 version.

Example legacy URL that fails to redirect to bitstream
Old DSpace URL with space: https://tspace.library.utoronto.ca/bitstream/1807/68628/1/Powers%20of%20Exclusion%20Intro.pdf
Fails to redirect to https://utoronto.scholaris.ca/server/api/core/bitstreams/662429cf-2bc7-4efc-9e73-9302dbf3a7e1/content

This legacy URL is accessed through Google Scholar: https://scholar.google.ca/citations?view_op=view_citation&hl=en&user=zAF9iOEAAAAJ&citation_for_view=zAF9iOEAAAAJ:UeHWp8X0CEIC

Tried with Brave Browser, Firefox, Safari with same results

The spaces in the filename are encoded twice %20 resulting in %2520 character.

To Reproduce

Steps to reproduce the behavior:

  1. In a DSpace 7.6.2 instance, create an item and upload a bitstream with spaces in the filename.
  2. Access the bitstream directly using legacy DSpace URL pattern /bitstream/{prefix}/{suffix}/{sequenceId}/{filename}
  3. DSpace shows 404 error

Expected behavior

It should redirect to the bitstream instead of a 404 error.

Example legacy URL that successfully redirects to bitstream
Old DSpace URL without spaces: https://tspace.library.utoronto.ca/bitstream/1807/67582/1/images-of-community.pdf
Successfully redirects to https://utoronto.scholaris.ca/server/api/core/bitstreams/37c6806d-7c26-4fc8-a08e-5a251d2b8552/content

This legacy URL is accessed through Google Scholar:
https://scholar.google.ca/citations?view_op=view_citation&hl=en&user=zAF9iOEAAAAJ&citation_for_view=zAF9iOEAAAAJ:u-x6o8ySG0sC

Related work

We are currently working on a PR to dspace-7_x branch.

Encoding encodeURIComponent in bitstream-data.service.ts#L174 needs to be removed:

if (hasValue(filename)) {
  searchParams.push(new RequestParam('filename', encodeURIComponent(filename)));
}

RequestParam is already encoding filename

export class RequestParam {
  constructor(
    public fieldName: string,
    public fieldValue: any,
    public encodeValue = true,
  ) {
    if (encodeValue) {
      this.fieldValue = encodeURIComponent(fieldValue);
    }
  }
}
@msarmie msarmie added bug needs triage New issue needs triage and/or scheduling labels Jan 21, 2025
@github-project-automation github-project-automation bot moved this to 🆕 Triage in DSpace Backlog Jan 21, 2025
@tdonohue tdonohue added component: SEO Search Engine Optimization affects: main Issue impacts "main" (latest release). affects: 8.x Issue impacts 8.x releases affects: 7.x Issue impacts 7.x releases help wanted Needs a volunteer to claim to move forward and removed needs triage New issue needs triage and/or scheduling labels Jan 21, 2025
@tdonohue tdonohue added this to the 7.6.3 milestone Jan 22, 2025
@tdonohue
Copy link
Member

Fixed by #3876 in 7.6.3

@github-project-automation github-project-automation bot moved this from 📋 To Do to ✅ Done in DSpace 8.x and 7.6.x Maintenance Jan 22, 2025
@tdonohue tdonohue removed affects: main Issue impacts "main" (latest release). affects: 8.x Issue impacts 8.x releases help wanted Needs a volunteer to claim to move forward labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: 7.x Issue impacts 7.x releases bug component: SEO Search Engine Optimization
Projects
Development

No branches or pull requests

2 participants