Date: Sun, 3 Oct 1999 13:55:09 +0200 From: Alexander Langer <alex@cichlids.com> To: freebsd-hackers@freebsd.org Subject: vis(3), unvis(3), HTTP-URIs and libfetch Message-ID: <19991003135509.A4465@cichlids.cichlids.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hello!
in fetch(3) we read:
BUGS
No attempt is made to encode spaces etc. within URLs. Spaces in
the docu-
ment part of an URLshould be replaced with "%20" in HTTP
URLs and "\ " in
FTP URLs.
I've started this encoding. DES told me to implement this in vis(3).
This is done by the attached patch and works here.
Example:
/bla bla/~tst/foo?test=foo+bar&bla=$string
becomes
/bla%20bla/%7Etest/foo?test=foo+bar&bla=$string
in a minimal application.
I added a new style const, VIS_HTTPSTYLE (as VIS_CSTYLE) to vis.h,
patch is also attached.
So libfetch can use vis(3) with the VIS_HTTPSTYLE flag to encode
HTTP-URIs, FTP-encoding could be added later easily, too.
But now I'm getting problems, that's why I write here:
unvis(3) wants to decode HTTPSTYLE strings.
while this is no problem for unvis(), I cannot add this to
int
strunvis(char *dst, const char *src)
because strunvis() really misses a flag param to tell it, how to
decode.
I need a new function - a new name.
I propose something like
int strunvisx(char *dst, const char *src, int flag);
strunvisx (or what the name will be) checks the flag.
If it is VIS_HTTPSTYLE it will use unvis() with the VIS_HTTPSTYLE
flag to decode the string.
If it is VIS_FTPSTYLE (implemented later), it'll use unvis() with
VIS_FTPSTYLE.
In every other case strunvisx() just calls strunvis().
Alex
--
I doubt, therefore I might be.
[-- Attachment #2 --]
--- /usr/src/lib/libc/gen/vis.c Fri Jul 12 20:54:15 1996
+++ vis.c Sat Oct 2 20:20:17 1999
@@ -52,6 +52,21 @@
register int flag;
{
c = (unsigned char)c;
+
+ if (flag & VIS_HTTPSTYLE) {
+ if (!((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z')
+ || (c >= 'a' && c <= 'z') || c == '$' || c == '-'
+ || c == '_' || c == '\'' || c == '+' || c == '!' ||
+ c == '(' || c == ')' || c == ',' || c == '"' ||
+ c == ';' || c == '/' || c == '?' || c == ':' ||
+ c == '@' || c == '&' || c == '=' || c == '+')) {
+ *dst++ = '%';
+ snprintf(dst, 4, (c < 16 ? "0%X" : "%X"), c);
+ dst += 2;
+ goto done;
+ }
+ }
+
if (isgraph(c) ||
((flag & VIS_SP) == 0 && c == ' ') ||
((flag & VIS_TAB) == 0 && c == '\t') ||
[-- Attachment #3 --]
--- /usr/src/include/vis.h Sun Aug 29 16:38:58 1999
+++ vis.h Sun Oct 3 13:45:00 1999
@@ -64,6 +64,7 @@
* other
*/
#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
+#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */
/*
* unvis return codes
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991003135509.A4465>
