1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

lejp-conf: allow header value part to exceed one string chunk

This commit is contained in:
Andy Green 2018-08-24 16:10:36 +08:00
parent 290208c19e
commit a0c558df11

View file

@ -205,6 +205,7 @@ struct jpargs {
unsigned int enable_client_ssl:1; unsigned int enable_client_ssl:1;
unsigned int fresh_mount:1; unsigned int fresh_mount:1;
unsigned int any_vhosts:1; unsigned int any_vhosts:1;
unsigned int chunk:1;
}; };
static void * static void *
@ -213,6 +214,8 @@ lwsws_align(struct jpargs *a)
if ((lws_intptr_t)(a->p) & 15) if ((lws_intptr_t)(a->p) & 15)
a->p += 16 - ((lws_intptr_t)(a->p) & 15); a->p += 16 - ((lws_intptr_t)(a->p) & 15);
a->chunk = 0;
return a->p; return a->p;
} }
@ -413,16 +416,19 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
} }
/* this catches, eg, vhosts[].headers[].xxx */ /* this catches, eg, vhosts[].headers[].xxx */
if (reason == LEJPCB_VAL_STR_END && if ((reason == LEJPCB_VAL_STR_END || reason == LEJPCB_VAL_STR_CHUNK) &&
ctx->path_match == LEJPVP_HEADERS_NAME + 1) { ctx->path_match == LEJPVP_HEADERS_NAME + 1) {
if (!a->chunk) {
headers = lwsws_align(a); headers = lwsws_align(a);
a->p += sizeof(*headers); a->p += sizeof(*headers);
n = lejp_get_wildcard(ctx, 0, a->p, a->end - a->p); n = lejp_get_wildcard(ctx, 0, a->p,
/* ie, enable this protocol, no options yet */ lws_ptr_diff(a->end, a->p));
/* ie, add this header */
headers->next = a->info->headers; headers->next = a->info->headers;
a->info->headers = headers; a->info->headers = headers;
headers->name = a->p; headers->name = a->p;
lwsl_notice(" adding header %s=%s\n", a->p, ctx->buf); lwsl_notice(" adding header %s=%s\n", a->p, ctx->buf);
a->p += n - 1; a->p += n - 1;
*(a->p++) = ':'; *(a->p++) = ':';
@ -432,6 +438,8 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
*(a->p - 1) = '\0'; *(a->p - 1) = '\0';
headers->value = a->p; headers->value = a->p;
headers->options = NULL; headers->options = NULL;
}
a->chunk = reason == LEJPCB_VAL_STR_CHUNK;
goto dostring; goto dostring;
} }
@ -750,6 +758,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
dostring: dostring:
p = ctx->buf; p = ctx->buf;
p[LEJP_STRING_CHUNK] = '\0';
p1 = strstr(p, ESC_INSTALL_DATADIR); p1 = strstr(p, ESC_INSTALL_DATADIR);
if (p1) { if (p1) {
n = p1 - p; n = p1 - p;
@ -762,6 +771,7 @@ dostring:
} }
a->p += lws_snprintf(a->p, a->end - a->p, "%s", p); a->p += lws_snprintf(a->p, a->end - a->p, "%s", p);
if (reason == LEJPCB_VAL_STR_END)
*(a->p)++ = '\0'; *(a->p)++ = '\0';
return 0; return 0;