improved url encoding api

This commit is contained in:
Unbit
2013-04-27 11:45:48 +02:00
parent 6cf67b399c
commit cdc41c305e
2 changed files with 27 additions and 0 deletions
+26
View File
@@ -3104,6 +3104,7 @@ void http_url_decode(char *buf, uint16_t * len, char *dst) {
}
/*
we scan the table in reverse, as updated values are at the end
*/
@@ -3911,3 +3912,28 @@ char *uwsgi_str_to_hex(char *src, size_t slen) {
}
return dst;
}
// dst has to be 3 times buf size (USE IT ONLY FOR PATH_INFO !!!)
void http_url_encode(char *buf, uint16_t *len, char *dst) {
uint16_t i;
char *ptr = dst;
for(i=0;i<*len;i++) {
if ((buf[i] >= 'A' && buf[i] <= 'Z') ||
(buf[i] >= 'a' && buf[i] <= 'z') ||
(buf[i] >= '0' && buf[i] <= '9') ||
buf[i] == '-' || buf[i] == '_' || buf[i] == '.' || buf[i] == '~' || buf[i] == '/' ) {
*ptr++= buf[i];
}
else {
char *h = uwsgi_hex_table[(int) buf[i]];
*ptr++= '%';
*ptr++= h[0];
*ptr++= h[1];
}
}
*len = ptr-dst;
}
+1
View File
@@ -3060,6 +3060,7 @@ void uwsgi_fixup_fds(int, int, struct uwsgi_gateway *);
void uwsgi_set_processname(char *);
void http_url_decode(char *, uint16_t *, char *);
void http_url_encode(char *, uint16_t *, char *);
pid_t uwsgi_fork(char *);