diff options
author | Joe Orton <jorton@apache.org> | 2024-02-07 16:26:27 +0100 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2024-02-07 16:26:27 +0100 |
commit | a046be0dacdce203d7668ff8a4acd9610138b1d4 (patch) | |
tree | 70825e48b1279a477ae731f81788280acf4b74ed | |
parent | fr doc rebuild. (diff) | |
download | apache2-a046be0dacdce203d7668ff8a4acd9610138b1d4.tar.xz apache2-a046be0dacdce203d7668ff8a4acd9610138b1d4.zip |
* modules/filters/mod_xml2enc.c (xml2enc_ffunc): Accept any XML media
type per RFC 7303, plus any text/ type.
PR: 64339
Github: closes #409
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915625 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | modules/filters/mod_xml2enc.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/modules/filters/mod_xml2enc.c b/modules/filters/mod_xml2enc.c index e8ee264795..8425815d3e 100644 --- a/modules/filters/mod_xml2enc.c +++ b/modules/filters/mod_xml2enc.c @@ -329,7 +329,7 @@ static apr_status_t xml2enc_ffunc(ap_filter_t* f, apr_bucket_brigade* bb) apr_bucket* bstart; apr_size_t insz = 0; int pending_meta = 0; - char *ctype; + char *mtype; char *p; if (!ctx || !f->r->content_type) { @@ -338,13 +338,17 @@ static apr_status_t xml2enc_ffunc(ap_filter_t* f, apr_bucket_brigade* bb) return ap_pass_brigade(f->next, bb) ; } - ctype = apr_pstrdup(f->r->pool, f->r->content_type); - for (p = ctype; *p; ++p) - if (isupper(*p)) - *p = tolower(*p); - - /* only act if starts-with "text/" or contains "+xml" */ - if (strncmp(ctype, "text/", 5) && !strstr(ctype, "+xml")) { + /* Extract the media type, ignoring parameters in content-type. */ + mtype = apr_pstrdup(f->r->pool, f->r->content_type); + if ((p = ap_strchr(mtype, ';')) != NULL) *p = '\0'; + ap_str_tolower(mtype); + + /* Accept text/ types, plus any XML media type per RFC 7303. */ + if (!(strncmp(mtype, "text/", 5) == 0 + || strcmp(mtype, "application/xml") == 0 + || (strlen(mtype) > 7 /* minimum 'a/b+xml' length */ + && (p = strstr(mtype, "+xml")) != NULL + && strlen(p) == 4 /* ensures +xml is a suffix */))) { ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb) ; } |