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

Failure to open url with "C:\" in url #8946

Closed
rr326 opened this issue Sep 23, 2017 · 2 comments
Closed

Failure to open url with "C:\" in url #8946

rr326 opened this issue Sep 23, 2017 · 2 comments
Labels

Comments

@rr326
Copy link

rr326 commented Sep 23, 2017

Configuration:

  • Web browser and its version:
    Electron 1.6
  • Operating system and its version:
    Windows 10
  • PDF.js version:
    (These are pdfjs-dist)
    Works: v1.9.426
    Doesn't work: Latest - eg: 1.9.583
  • Is an extension: No

Steps to reproduce the problem:

  1. Try to open a file url: "file://C:\Users\John Doe\test.pdf"
    PDFJS.getDocument( "file://C:\Users\John Doe\test.pdf")...
    2.ENOENT: no such file or directory, lstat 'C:\C:\Users\John%20Doe\test.pdf"

I've spent a bunch of time on this, and I think there are two issues:

  1. the encoded space, which is fixed in 8907
  2. the file://C:... gets transformed to file:///C:... (extra slash), and then it later sees the / for the filesystem, and adds another c:\ to the front.

Note - this whole file://c:... works as expected in v1.9.426 (even with the encoded space).

@mukulmishra18
Copy link
Contributor

Similar to #8907 . We have to decode the url using decodeURI to get the correct file system path. There is a PR for this issue #8928 .

@juncaixinchi
Copy link
Contributor

this error still exists ... decodeURI is not working

path before decodeURI: /C:/User/1234/Desktop/a.pdf

after decodeURI, path is still the same

fs.lstat would transfrom it to C:\C:\User\1234\Desktop\a.pdf and then this error occurred

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants