httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r1800917 - /httpd/httpd/trunk/modules/mappers/mod_negotiation.c
Date Wed, 05 Jul 2017 19:42:30 GMT
Author: wrowe
Date: Wed Jul  5 19:42:30 2017
New Revision: 1800917

URL: http://svn.apache.org/viewvc?rev=1800917&view=rev
Log:
Fix negotiation type parsing to be strict about "*", "*/*" and "type/*"
comparisons.

Submitted by: wrowe, Robert Święcki <robert swiecki.net>


Modified:
    httpd/httpd/trunk/modules/mappers/mod_negotiation.c

Modified: httpd/httpd/trunk/modules/mappers/mod_negotiation.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_negotiation.c?rev=1800917&r1=1800916&r2=1800917&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_negotiation.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_negotiation.c Wed Jul  5 19:42:30 2017
@@ -1332,14 +1332,19 @@ static int mime_match(accept_rec *accept
     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;
         }



Mime
View raw message