diff options
author | Nick Kew <niq@apache.org> | 2020-06-06 22:54:32 +0000 |
---|---|---|
committer | Nick Kew <niq@apache.org> | 2020-06-06 22:54:32 +0000 |
commit | 5a64355b3f1d3cdb33712a1b233c14e37f1d2565 (patch) | |
tree | 4636b71dd9e62c0e672cd84f76b453a3e3303949 /modules/filters | |
parent | 7c3d991da630568838ce8e4670588d99bc468a2e (diff) | |
download | httpd-5a64355b3f1d3cdb33712a1b233c14e37f1d2565.tar.gz |
PR#64443: watch whether mod_proxy_html i18n might risk messing up FORM
submission, and insert accept-charset attribute if necessary.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1878553 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/filters')
-rw-r--r-- | modules/filters/mod_proxy_html.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/filters/mod_proxy_html.c b/modules/filters/mod_proxy_html.c index 66b56a367c..685cb8be57 100644 --- a/modules/filters/mod_proxy_html.c +++ b/modules/filters/mod_proxy_html.c @@ -417,6 +417,9 @@ static void pstartElement(void *ctxt, const xmlChar *uname, const char** attrs = (const char**) uattrs; const htmlElemDesc* desc = htmlTagLookup(uname); urlmap *themap = ctx->map; + const char *accept_charset = NULL; + + #ifdef HAVE_STACK const void** descp; #endif @@ -446,6 +449,21 @@ static void pstartElement(void *ctxt, const xmlChar *uname, /* TODO - implement HTML "allowed here" */ #endif + /* PR#64443: for <FORM>, insert accept-charset attribute if necessary + * It's necessary if we've changed the charset (i.e. input not UTF-8) + * UNLESS someone has taken charge. + * If there's already an accept-charset, then the backend is in charge. + * If ProxyHTMLCharsetOut is set, the sysop has taken charge. + */ + if ((xml2enc_charset != NULL) && (ctx->cfg->charset_out == NULL) + && !strcasecmp(name, "FORM")) { + xmlCharEncoding enc; + if ((xml2enc_charset(ctx->f->r, &enc, &accept_charset) != APR_SUCCESS) + || (enc == XML_CHAR_ENCODING_UTF8)) { + accept_charset = NULL; /* Now pay attention if not NULL */ + } + } + ap_fputc(ctx->f->next, ctx->bb, '<'); ap_fputs(ctx->f->next, ctx->bb, name); @@ -672,8 +690,17 @@ static void pstartElement(void *ctxt, const xmlChar *uname, pcharacters(ctx, (const xmlChar*)ctx->buf, strlen(ctx->buf)); ap_fputc(ctx->f->next, ctx->bb, '"'); } + /* PR#64443: watch for accept-charset from backend */ + if (accept_charset && !strcasecmp(a[0], "accept-charset")) { + accept_charset = NULL; + } } } + /* PR#64443: we've seen all we need, so add accept-charset if necessary */ + if (accept_charset != NULL) { + ap_fprintf(ctx->f->next, ctx->bb, " accept-charset=\"%s\"", + accept_charset); + } ctx->offset = 0; if (desc && desc->empty) ap_fputs(ctx->f->next, ctx->bb, ctx->etag); |