summaryrefslogtreecommitdiff
path: root/modules/http/mod_mime.c
diff options
context:
space:
mode:
authorBrian Pane <brianp@apache.org>2001-12-08 02:00:42 +0000
committerBrian Pane <brianp@apache.org>2001-12-08 02:00:42 +0000
commitdc85b1450c82d35df81ca9a90679a24912f34353 (patch)
tree472020fe65a7ed69d5cabe1db09b8b5bfd89ed40 /modules/http/mod_mime.c
parent0f469a62f82ec28f68ad28c94101b7de36dbb3e5 (diff)
downloadhttpd-dc85b1450c82d35df81ca9a90679a24912f34353.tar.gz
Reduced the number of times that we scan through each string
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
Diffstat (limited to 'modules/http/mod_mime.c')
-rw-r--r--modules/http/mod_mime.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/modules/http/mod_mime.c b/modules/http/mod_mime.c
index 77ed062edd..932eb484a2 100644
--- a/modules/http/mod_mime.c
+++ b/modules/http/mod_mime.c
@@ -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);