* added the Unlicense as valid in misc/share/REGISTER
[t2sde.git] / package / network / fget / http-urlencode.patch
blob040901c0da97d784f5c3976dc501e29de6ba4d3e
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/fget/http-urlencode.patch
3 # Copyright (C) 2024 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 --- ./fget.c.vanilla 2024-03-20 13:26:53.078325517 +0100
15 +++ ./fget.c 2024-03-20 13:38:30.234325849 +0100
16 @@ -112,10 +112,21 @@
17 static stralloc auth = {0};
18 static stralloc b64 = {0};
19 static char base64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
20 + static char hex[]="0123456789ABCDEF";
21 char buf[20];
23 stralloc_copys(request,"GET ");
24 - stralloc_cats(request,path);
25 + // url escape
26 + for (unsigned char c; *path; path++) {
27 + c = *path;
28 + if (isalnum(c) || (c >= '-' && c <= '/') || (c == '~')) {
29 + stralloc_append(request,path);
30 + } else {
31 + stralloc_append(request,"%");
32 + stralloc_append(request,hex+(c>>4));
33 + stralloc_append(request,hex+(c&0xf));
34 + }
35 + }
36 stralloc_cats(request," HTTP/1.0\r\nHost: ");
37 stralloc_cat(request,&host);
38 stralloc_cats(request,":");