]> granicus.if.org Git - apache/commitdiff
Reduced the number of times that we scan through each string
authorBrian Pane <brianp@apache.org>
Sat, 8 Dec 2001 02:00:42 +0000 (02:00 +0000)
committerBrian Pane <brianp@apache.org>
Sat, 8 Dec 2001 02:00:42 +0000 (02:00 +0000)
looking for invalid characters in analyze_ct()

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92388 13f79535-47bb-0310-9956-ffa450edef68

modules/http/mod_mime.c

index 77ed062edd7f1d0aec77f98ad2c70b1ae5dbcbd4..932eb484a262b31bc706df88b8ec580314b6afc8 100644 (file)
@@ -529,8 +529,7 @@ static int is_quoted_pair(const char *s)
 
 static content_type *analyze_ct(request_rec *r, const char *s)
 {
-    const char *cp;
-    const char *mp;
+    const char *cp, *mp, *tmp;
     char *attribute, *value;
     int quoted = 0;
     server_rec * ss = r->server;
@@ -555,13 +554,18 @@ static content_type *analyze_ct(request_rec *r, const char *s)
        return (NULL);
     }
     ctp->type = zap_sp_and_dup(p, mp, cp, NULL);
-    if (ctp->type == NULL || *(ctp->type) == '\0' ||
-       strchr(ctp->type, ';') || strchr(ctp->type, ' ') ||
-       strchr(ctp->type, '\t')) {
+    if (ctp->type == NULL || *(ctp->type) == '\0') {
        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ss,
                     "Cannot get media subtype.");
        return (NULL);
     }
+    for (tmp = ctp->type; *tmp; tmp++) {
+      if ((*tmp == ';') || (*tmp == ' ') || (*tmp == '\t')) {
+       ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ss,
+                    "Cannot get media subtype.");
+       return (NULL);
+      }
+    }
 
     /* getting a subtype */
     cp++;
@@ -570,11 +574,17 @@ static content_type *analyze_ct(request_rec *r, const char *s)
     for (; *cp != ';' && *cp != '\0'; cp++)
         continue;
     ctp->subtype = zap_sp_and_dup(p, mp, cp, NULL);
-    if ((ctp->subtype == NULL) || (*(ctp->subtype) == '\0') ||
-       strchr(ctp->subtype, ' ') || strchr(ctp->subtype, '\t')) {
+    if ((ctp->subtype == NULL) || (*(ctp->subtype) == '\0')) {
+       ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ss,
+                    "Cannot get media subtype.");
+       return (NULL);
+    }
+    for (tmp = ctp->subtype; *tmp; tmp++) {
+      if ((*tmp == ' ') || (*tmp == '\t')) {
        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ss,
                     "Cannot get media subtype.");
        return (NULL);
+      }
     }
     if (*cp == '\0') {
         return (ctp);