3rd / image.nvim

🖼️ Bringing images to Neovim.
MIT License
1.02k stars 42 forks source link

Curl gives an error (maybe related to query string parameters handling?) #169

Closed metalelf0 closed 4 months ago

metalelf0 commented 4 months ago

Heya. I'm using this plugin with markdown files and kitty.

The following line works fine and renders the image correctly:

![photo by Nikita Pishchugin on Unsplash](https://images.unsplash.com/photo-1714514828598-70dbbc1c13fb)

This one fails with a curl error:

![photo by Nikita Pishchugin on Unsplash](https://images.unsplash.com/photo-1714514828598-70dbbc1c13fb?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzNjM5Nzd8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MTU1ODIxMjV8&ixlib=rb-4.0.3&q=85&fit=crop&w=1200&h=300)

The error I see in :messages output is the following one:

Error executing luv callback:
...al/share/nvim/lazy/image.nvim/lua/image/utils/logger.lua:54: 09:13:13.479600 [image.nvim] image: curl errored while downloading https://images.unsplash.com/photo-1714514828598-70dbbc1c13fb?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzNjM5Nzd8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MTU1ODIxMjV8&ixlib=rb-4.0.3&q=85&fit=crop&w=1200&h=300 {
  code = 23,
  signal = 0
}
stack traceback:
    [C]: in function 'handler'
    ...al/share/nvim/lazy/image.nvim/lua/image/utils/logger.lua:54: in function 'throw'
    ...ni/.local/share/nvim/lazy/image.nvim/lua/image/image.lua:365: in function <...ni/.local/share/nvim/lazy/image.nvim/lua/image/image.lua:363>

Manually downloading the url above with curl, as in curl --output /tmp/image.jpg <url>, works correctly. Not sure if you're using system curl in your plugin or any libcurl wrapper, though.

3rd commented 4 months ago

It's hitting a "filename too long" error because we're doing a base64(image.id), and the image id contains the url, so it can get really long. Opened a PR with a simple (and possibly wrong) way of hashing, looking for better ways.