FreeBSD Bugzilla – Attachment 9137 Details for
Bug 18829
add HTTP-URI-encoding to vis(3) and unvis(3)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.12 KB, created by
alex
on 2000-05-26 12:40:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
alex
Created:
2000-05-26 12:40:01 UTC
Size:
2.12 KB
patch
obsolete
>--- /usr/src/lib/libc/gen/unvis.c Fri Jul 12 20:54:14 1996 >+++ unvis.c Sun Oct 24 13:39:08 1999 >@@ -48,8 +48,12 @@ > #define S_CTRL 4 /* control char started (^) */ > #define S_OCTAL2 5 /* octal digit 2 */ > #define S_OCTAL3 6 /* octal digit 3 */ >+#define S_HEX2 7 /* hex digit 2 */ >+ >+#define S_HTTP 0x080 /* %HEXHEX escape */ > > #define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') >+#define ishex(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '9' || ((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f') > > /* > * unvis - decode characters previously encoded by vis >@@ -68,7 +72,7 @@ > return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD); > } > >- switch (*astate) { >+ switch (*astate & ~S_HTTP) { > > case S_GROUND: > *cp = 0; >@@ -76,10 +80,21 @@ > *astate = S_START; > return (0); > } >+ if (flag & VIS_HTTPSTYLE && c == '%') { >+ *astate = S_START | S_HTTP; >+ return (0); >+ } > *cp = c; > return (UNVIS_VALID); > > case S_START: >+ if (*astate & S_HTTP) { >+ if (ishex(tolower(c))) { >+ *cp = isdigit(c) ? (c - '0') : (tolower(c) - 'a'); >+ *astate = S_HEX2; >+ return (0); >+ } >+ } > switch(c) { > case '\\': > *cp = c; >@@ -199,6 +214,13 @@ > */ > return (UNVIS_VALIDPUSH); > >+ case S_HEX2: /* second mandatory hex digit */ >+ if (ishex(tolower(c))) { >+ *cp = (isdigit(c) ? (*cp << 4) + (c - '0') : (*cp << 4) + (tolower(c) - 'a' + 10)); >+ } >+ *astate = S_GROUND; >+ return (UNVIS_VALID); >+ > default: > /* > * decoder in unknown state - (probably uninitialized) >@@ -227,6 +249,37 @@ > while ( (c = *src++) ) { > again: > switch (unvis(dst, c, &state, 0)) { >+ case UNVIS_VALID: >+ dst++; >+ break; >+ case UNVIS_VALIDPUSH: >+ dst++; >+ goto again; >+ case 0: >+ case UNVIS_NOCHAR: >+ break; >+ default: >+ return (-1); >+ } >+ } >+ if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID) >+ dst++; >+ *dst = '\0'; >+ return (dst - start); >+} >+ >+int >+strunvisx(dst, src, flag) >+ register char *dst; >+ register const char *src; >+{ >+ register char c; >+ char *start = dst; >+ int state = 0; >+ >+ while ( (c = *src++) ) { >+ again: >+ switch (unvis(dst, c, &state, flag)) { > case UNVIS_VALID: > dst++; > break;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 18829
:
9136
| 9137 |
9138