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

Encode URL for lubcurl, such as spaces to %20 #780

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nigels-com
Copy link

Curl requires RFC-3986 encoded Uniform Resource Identifiers (URI).

In particular there is a percent-encoding for characters such as space (%20)

2.1.  Percent-Encoding

   A percent-encoding mechanism is used to represent a data octet in a
   component when that octet's corresponding character is outside the
   allowed set or is being used as a delimiter of, or within, the
   component.  A percent-encoded octet is encoded as a character
   triplet, consisting of the percent character "%" followed by the two
   hexadecimal digits representing that octet's numeric value.  For
   example, "%20" is the percent-encoding for the binary octet
   "00100000" (ABNF: %x20), which in US-ASCII corresponds to the space
   character (SP).  Section 2.4 describes when percent-encoding and
   decoding is applied.

      pct-encoded = "%" HEXDIG HEXDIG

I came across this limitation of feh by loading images via curl with space characters in their file name.

This change uses the libcurl URL parsing API to perform the appropriate encoding.

Sample debug logging for successful space-containing file name.
(This case fails for feh without this change)

...
inwidget.c  +829  winwidget_loadimage  : filename http://nas.lan/PhotoFrame/Christmas (Artistic)_18_3 (Hi-Res).png
imlib.c      +345  feh_load_image       : filename is http://nas.lan/PhotoFrame/Christmas (Artistic)_18_3 (Hi-Res).png, image is 0x55852576c8
imlib.c      +890  feh_http_load_image  : url http://nas.lan/PhotoFrame/Christmas (Artistic)_18_3 (Hi-Res).png, encoded http://nas.lan/PhotoFrame/Christmas%20(Artistic)_18_3%20(Hi-Res).png
imlib.c      +911  feh_http_load_image  : sfn is /tmp/feh_curl_XXXXXX_Christmas (Artistic)_18_3 (Hi-Res).png
*   Trying 192.168.2.100:80...
* Connected to nas.lan (192.168.2.100) port 80 (#0)
> GET /PhotoFrame/Christmas%20(Artistic)_18_3%20(Hi-Res).png HTTP/1.1
Host: nas.lan
User-Agent: feh/
Accept: */*

< HTTP/1.1 200 OK
...

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

Successfully merging this pull request may close these issues.

1 participant