# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/fget/http-urlencode.patch # Copyright (C) 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- --- ./fget.c.vanilla 2024-03-20 13:26:53.078325517 +0100 +++ ./fget.c 2024-03-20 13:38:30.234325849 +0100 @@ -112,10 +112,21 @@ static stralloc auth = {0}; static stralloc b64 = {0}; static char base64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + static char hex[]="0123456789ABCDEF"; char buf[20]; stralloc_copys(request,"GET "); - stralloc_cats(request,path); + // url escape + for (unsigned char c; *path; path++) { + c = *path; + if (isalnum(c) || (c >= '-' && c <= '/') || (c == '~')) { + stralloc_append(request,path); + } else { + stralloc_append(request,"%"); + stralloc_append(request,hex+(c>>4)); + stralloc_append(request,hex+(c&0xf)); + } + } stralloc_cats(request," HTTP/1.0\r\nHost: "); stralloc_cat(request,&host); stralloc_cats(request,":");