URL UTF-8 Bugfix
This commit is contained in:
@ -146,7 +146,7 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int
|
|||||||
if (strcmp(uri.uri, buf0) != 0 || change_proto) {
|
if (strcmp(uri.uri, buf0) != 0 || change_proto) {
|
||||||
res.status = http_get_status(308);
|
res.status = http_get_status(308);
|
||||||
size = sizeof(buf0);
|
size = sizeof(buf0);
|
||||||
encode_url(uri.uri, buf0, &size);
|
url_encode(uri.uri, buf0, &size);
|
||||||
if (change_proto) {
|
if (change_proto) {
|
||||||
sprintf(buf1, "https://%s%s", host, buf0);
|
sprintf(buf1, "https://%s%s", host, buf0);
|
||||||
http_add_header_field(&res.hdr, "Location", buf1);
|
http_add_header_field(&res.hdr, "Location", buf1);
|
||||||
|
@ -23,7 +23,7 @@ char *format_duration(unsigned long micros, char *buf) {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int url_encode(const char *str, char *enc, ssize_t *size) {
|
int url_encode_component(const char *str, char *enc, ssize_t *size) {
|
||||||
char *ptr = enc;
|
char *ptr = enc;
|
||||||
char ch;
|
char ch;
|
||||||
memset(enc, 0, *size);
|
memset(enc, 0, *size);
|
||||||
@ -50,7 +50,7 @@ int url_encode(const char *str, char *enc, ssize_t *size) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int encode_url(const char *str, char *enc, ssize_t *size) {
|
int url_encode(const char *str, char *enc, ssize_t *size) {
|
||||||
char *ptr = enc;
|
char *ptr = enc;
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
memset(enc, 0, *size);
|
memset(enc, 0, *size);
|
||||||
@ -89,6 +89,9 @@ int url_decode(const char *str, char *dec, ssize_t *size) {
|
|||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
ch = (char) strtol(buf, NULL, 16);
|
ch = (char) strtol(buf, NULL, 16);
|
||||||
i += 2;
|
i += 2;
|
||||||
|
} else if (ch == '?') {
|
||||||
|
strcpy(ptr, str + i);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ptr[0] = ch;
|
ptr[0] = ch;
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ char *log_prefix;
|
|||||||
|
|
||||||
char *format_duration(unsigned long micros, char *buf);
|
char *format_duration(unsigned long micros, char *buf);
|
||||||
|
|
||||||
int url_encode(const char *str, char *enc, ssize_t *size);
|
int url_encode_component(const char *str, char *enc, ssize_t *size);
|
||||||
|
|
||||||
int encode_url(const char *str, char *enc, ssize_t *size);
|
int url_encode(const char *str, char *enc, ssize_t *size);
|
||||||
|
|
||||||
int url_decode(const char *str, char *dec, ssize_t *size);
|
int url_decode(const char *str, char *dec, ssize_t *size);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user