Skip to content

Commit

Permalink
url cleaning: leave // after http[s]: alone
Browse files Browse the repository at this point in the history
  • Loading branch information
lws-team committed Jul 21, 2017
1 parent 09f3947 commit 6c09952
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,17 @@ lws_unauthorised_basic_auth(struct lws *wsi)

int lws_clean_url(char *p)
{
if (p[0] == 'h' && p[1] == 't' && p[2] == 't' && p[3] == 'p') {
p += 4;
if (*p == 's')
p++;
if (*p == ':') {
p++;
if (*p == '/')
p++;
}
}

while (*p) {
if (p[0] == '/' && p[1] == '/') {
char *p1 = p;
Expand Down Expand Up @@ -997,7 +1008,10 @@ lws_http_action(struct lws *wsi)
"%s%s%s/", oprot[!!lws_is_ssl(wsi)],
lws_hdr_simple_ptr(wsi, WSI_TOKEN_HOST),
uri_ptr);

lwsl_notice("%s\n", end);
lws_clean_url((char *)end);
lwsl_notice("%s\n", end);

n = lws_http_redirect(wsi, HTTP_STATUS_MOVED_PERMANENTLY,
end, n, &p, end);
Expand Down

0 comments on commit 6c09952

Please sign in to comment.