diff options
author | William A. Rowe Jr <wrowe@apache.org> | 2017-07-05 21:42:30 +0200 |
---|---|---|
committer | William A. Rowe Jr <wrowe@apache.org> | 2017-07-05 21:42:30 +0200 |
commit | e445cf5181f2e91e8ad04c1a5da26791584a53a5 (patch) | |
tree | 8e54befa1707be57487b7c23ffe441404a38a2f7 /modules | |
parent | Backported. (diff) | |
download | apache2-e445cf5181f2e91e8ad04c1a5da26791584a53a5.tar.xz apache2-e445cf5181f2e91e8ad04c1a5da26791584a53a5.zip |
Fix negotiation type parsing to be strict about "*", "*/*" and "type/*"
comparisons.
Submitted by: wrowe, Robert Święcki <robert swiecki.net>
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1800917 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mappers/mod_negotiation.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index baa28149dd..5ff205be61 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -1332,14 +1332,19 @@ static int mime_match(accept_rec *accept_r, var_rec *avail) const char *avail_type = avail->mime_type; int len = strlen(accept_type); - if (accept_type[0] == '*') { /* Anything matches star/star */ + if ((len == 1 && accept_type[0] == '*') + || (len == 3 && !strncmp(accept_type, "*/*", 3))) { + /* Anything matches star or star/star */ if (avail->mime_stars < 1) { avail->mime_stars = 1; } return 1; } - else if ((accept_type[len - 1] == '*') && - !strncmp(accept_type, avail_type, len - 2)) { + else if (len > 2 && accept_type[len - 2] == '/' + && accept_type[len - 1] == '*' + && !strncmp(accept_type, avail_type, len - 2) + && avail_type[len - 2] == '/') { + /* Any subtype matches for type/star */ if (avail->mime_stars < 2) { avail->mime_stars = 2; } |