roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.78k stars 501 forks source link

roo attempts to open file URL without first encoding spaces in filename. #567

Open Beartech opened 2 years ago

Beartech commented 2 years ago

Issue

I am using Jquery upload to direct upload spreadsheets to AWS for later processing by delayed_job. When a file name had spaces the URL being stored was not encoded to replace the spaces with %20. When roo tried to open the file it got:

URI::InvalidURIError: bad URI(is not URI?): "https://..."

My workaround was to encode the file name in the JS using encodeURI(filename)

This works but it might be better if roo looked for spaces to encode in the url when making a request. I also notice that my web console is complaining: roo-2.8.3/lib/roo/spreadsheet.rb:27: warning: URI.escape is obsolete and: roo-2.8.3/lib/roo/base.rb:547: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open

I'm wondering if these area causing my issue. I will fork and attempt to update the deprecated code, and if this does not fix my original issue I will attempt to add some code to check for the need to url escape resources that are being pulled down from the internet vs local files and escape them.

System configuration

Roo version: 2.8.3

Ruby version: 2.74.

OleksandrPoltavets commented 2 years ago

I have the same issue trying to open a file directly from AWS S3.