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

Fails for image file names containing spaces #7

Open
cristim opened this issue Oct 11, 2016 · 0 comments
Open

Fails for image file names containing spaces #7

cristim opened this issue Oct 11, 2016 · 0 comments

Comments

@cristim
Copy link

cristim commented Oct 11, 2016

Steps to reproduce

  • Check out my project containing a gulpfile.js using this library: git clone https://github.com/cristim/img-to-base64-html-converter.git
  • cd img-to-base64-html-converter && npm install
  • Save a website which contains spaces in the file name, the easiest is to use the above URL, and save the page to the same directory, using the "Save as" context menu(I did it in Chrome).
  • running gulp in the same directory would return this error
[23:25:18] Using gulpfile /tmp/test/img-to-base64-html-converter/gulpfile.js
[23:25:18] Starting 'default'...
[23:25:18] Finished 'default' after 12 ms
mtype:  application/octet-stream
mtype:  application/octet-stream
mtype:  image/gif
/tmp/test/img-to-base64-html-converter/cristim_img-to-base64-html-converter_%20Converts%20external%20images%20referenced%20from%20an%20HTML%20file%20into%20inlined%20base64%20img%20tags_files/octocat-spinner-32.gif image/gif
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/tmp/test/img-to-base64-html-converter/cristim_img-to-base64-html-converter_%20Converts%20external%20images%20referenced%20from%20an%20HTML%20file%20into%20inlined%20base64%20img%20tags_files/octocat-spinner-32.gif'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at .<anonymous> (/tmp/test/img-to-base64-html-converter/node_modules/gulp-img64/index.js:37:23)
    at exports.each (/tmp/test/img-to-base64-html-converter/node_modules/cheerio/lib/api/traversing.js:226:24)
    at Transform._transform (/tmp/test/img-to-base64-html-converter/node_modules/gulp-img64/index.js:27:13)
    at Transform._read (/tmp/test/img-to-base64-html-converter/node_modules/gulp-img64/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Transform._write (/tmp/test/img-to-base64-html-converter/node_modules/gulp-img64/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/tmp/test/img-to-base64-html-converter/node_modules/gulp-img64/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/tmp/test/img-to-base64-html-converter/node_modules/gulp-img64/node_modules/readable-stream/lib/_stream_writable.js:227:5)

Apparently the spaces in the file name get escaped, which causes the failure.

Prepending file:// to the same string may fix it.

cristim added a commit to cristim/gulp-img64 that referenced this issue Oct 11, 2016
cristim added a commit to cristim/gulp-img64 that referenced this issue Oct 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant