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

ENOENT: no such file or directory, lstat with # encoded in filename #8987

Closed
njakob opened this issue Oct 2, 2017 · 8 comments
Closed

ENOENT: no such file or directory, lstat with # encoded in filename #8987

njakob opened this issue Oct 2, 2017 · 8 comments
Labels

Comments

@njakob
Copy link

njakob commented Oct 2, 2017

#8928 actually resolved the issue #8907 I open couple days ago. However, when filenames contain an encoded # character (%23), current decoding process do not handled it.

Configuration:

  • Web browser and its version:
    Electron 1.7.8
  • Operating system and its version:
    Fedora 25
  • PDF.js version:
    1.9.617

Steps to reproduce the problem:

  1. Open a locale file with an # encoded character file:///home/njakob/Foo%20Bar/document%23.pdf

What went wrong?

  • The error ENOENT: no such file or directory, lstat is raised.

Issue is related to the decodeURI usage which ignore decoding of %23.

Solution should also cover cases were the # is inside the path such as file:///home/njakob/Foo%23/document.pdf.

@mukulmishra18
Copy link
Contributor

I think we need to use decodeURIComponent instead of decodeURI because decodeURI may ignores decoding special characters.

@shikhar-scs
Copy link
Contributor

If this issue is still up, may I work on it please?

@mukulmishra18
Copy link
Contributor

@shikhar-scs it is yours!

@shikhar-scs
Copy link
Contributor

@mukulmishra18 as you have previously worked with pdf.js, so I guess you are sure that use decodeURIComponent instead of decodeURI will make the required changes. Correct ? do we need to do something more than this ?

@mukulmishra18
Copy link
Contributor

so I guess you are sure that use decodeURIComponent instead of decodeURI will make the required changes

I think it should solve the problem as decodeURI may ignore some of the special characters. But I would suggest to go through the documentations(decodeURI and decodeURIComponent) and read the difference between the two.

do we need to do something more than this ?

I don't think anything else is required for this issue.

@shikhar-scs
Copy link
Contributor

shikhar-scs commented Jan 15, 2018

@mukulmishra18
I tried doing the same, changed the decodeURI keyword to decodeURIComponent. Then ran gulp chromium, added it as an extension to chrome and tried opening a file whose name contained # but the file not found error persisted, even though, the same file without # in its name was opened by pdf.js.

(files from desktop are now not opened in the chrome browser I know #9361 but at least the framework of the pdf.js application loads which happened in the latter case mentioned above)

I had made the changes here

let path = decodeURI(this._url.path);

and here

let path = decodeURI(this._url.path);

Could you please look into it ?

@mukulmishra18
Copy link
Contributor

mukulmishra18 commented Jan 15, 2018

If you try to decode any url that contains %23 in it, using decodeURIComponent then it will decode just fine. So I think this should solve the problem.

Also note that you are using chrome extension, so node_stream was never used, because it is intended to use in node environment. I will suggest to create a node app that uses pdf.js and see if problem still persists.

Edit: I would suggest to use console.log as much as you can to see if code really executing.

@shikhar-scs
Copy link
Contributor

shikhar-scs commented Jan 15, 2018

Also note that you are using chrome extension, so node_stream was never used, because it is intended to use in node environment. I will suggest to create a node app that uses pdf.js and see if problem still persists.

Thank you so much for this information and also for your help.

movsb pushed a commit to movsb/pdf.js that referenced this issue Jul 14, 2018
…decodeURIcomponent

changed decodeURI to decodeURIComponent: Fixes mozilla#8987
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