Skip to content

File names with spaces do not open in version 1.4.1 #43

Description

@MichaelJohnSmith

File with names like "/images/test%20space.pdf" open without problem in version 1.4.0 but fail to open in 1.4.1
I am using Joomla version 5.4.2 and php 8.2

On investigation, the problem seems to be caused by code added to app.js in the function run(config) at lines 733-777

      try {
        file = new URL(decodeURIComponent(file)).href;
      } catch {
        file = encodeURIComponent(file).replaceAll("%2F", "/");
      }

When presented with a file variable containing the string "/images/test%20space.pdf" the URL constructor fails with the following error - URL constructor: /images/test space.pdf is not a valid URL.

The catch code converts the file name to "/images/test%2520space.pdf", resulting in the error

Missing PDF file.
PDF.js v5.4.149 (build: 9e2e9e209)
Message: Unexpected server response (404)
while retrieving PDF "https:// ... /images/test%2520space.pdf".

If the code block above is commented out, the file does open successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions