changeset 1166:6d2de3dccef1

only parse charset parameter for text/* media types
author corvid <corvid@lavabit.com>
date Sun, 07 Jun 2009 16:28:21 +0000
parents 17a265a70c5e
children dd4dbc109717
files src/misc.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/misc.c	Sun Jun 07 03:55:22 2009 +0000
+++ b/src/misc.c	Sun Jun 07 16:28:21 2009 +0000
@@ -198,6 +198,7 @@
                                char **charset)
 {
    const char *s;
+   bool_t is_text;
 
    if (major)
       *major = NULL;
@@ -211,6 +212,7 @@
    for (s = str; isalnum(*s) || (*s == '-'); s++);
    if (major)
       *major = dStrndup(str, s - str);
+   is_text = (s - str == 4) && !dStrncasecmp(str, "text", 4);
 
    if (*s == '/') {
       for (str = ++s; isalnum(*s) || (*s == '-'); s++);
@@ -218,7 +220,8 @@
          *minor = dStrndup(str, s - str);
    }
 
-   if (charset && *s) {
+   if (is_text && charset && *s) {
+      /* charset parameter is defined for text media type (RFC 2046) */
       const char terminators[] = " ;\t";
       const char key[] = "charset";