2005-10-25 [colin] 1.9.15cvs107
[claws.git] / src / procmime.c
index a9f1a4d4887f9ec8002c1f06f33fc531b803ea79..f281ebf1209c531dd1d7d1193526f597066d8f8b 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -980,8 +980,10 @@ gchar *procmime_get_tmp_file_name(MimeInfo *mimeinfo)
                if (basetmp == NULL)
                        basetmp = "mimetmp";
                basetmp = g_path_get_basename(basetmp);
-               if (*basetmp == '\0') basetmp = g_strdup("mimetmp");
+               if (*basetmp == '\0') 
+                       basetmp = g_strdup("mimetmp");
                base = conv_filename_from_utf8(basetmp);
+               g_free(basetmp);
                subst_for_shellsafe_filename(base);
        }
 
@@ -1482,6 +1484,8 @@ static void parse_parameters(const gchar *parameters, GHashTable *table)
 
                value[0] = '\0';
                value++;
+               while (value[0] == ' ')
+                       value++;
 
                g_strdown(attribute);
 
@@ -1518,6 +1522,18 @@ static void parse_parameters(const gchar *parameters, GHashTable *table)
                                *tmp = '\0';
                }
 
+               if (attribute) {
+                       while (attribute[0] == ' ')
+                               attribute++;
+                       while (attribute[strlen(attribute)-1] == ' ') 
+                               attribute[strlen(attribute)-1] = '\0';
+               } 
+               if (value) {
+                       while (value[0] == ' ')
+                               value++;
+                       while (value[strlen(value)-1] == ' ') 
+                               value[strlen(value)-1] = '\0';
+               }               
                if (strrchr(attribute, '*') != NULL) {
                        gchar *tmpattr;
 
@@ -1613,14 +1629,10 @@ static void procmime_parse_content_type(const gchar *content_type, MimeInfo *mim
                mimeinfo->subtype = g_strdup("plain");
                if (g_hash_table_lookup(mimeinfo->typeparameters,
                                       "charset") == NULL) {
-                       if (strcmp(conv_get_locale_charset_str(), CS_UTF_8))
-                               g_hash_table_insert(mimeinfo->typeparameters,
-                                           g_strdup("charset"),
-                                           g_strdup(conv_get_locale_charset_str()));
-                       else
-                               g_hash_table_insert(mimeinfo->typeparameters,
-                                           g_strdup("charset"),
-                                           g_strdup(CS_ISO_8859_1));
+                       g_hash_table_insert(mimeinfo->typeparameters,
+                                   g_strdup("charset"),
+                                   g_strdup(
+                                       conv_get_locale_charset_str_no_utf8()));
                }
        } else {
                gchar *type, *subtype, *params;
@@ -1723,14 +1735,10 @@ int procmime_parse_mimepart(MimeInfo *parent,
                mimeinfo->subtype = g_strdup("plain");
                if (g_hash_table_lookup(mimeinfo->typeparameters,
                                       "charset") == NULL) {
-                       if (strcmp(conv_get_locale_charset_str(), CS_UTF_8))
-                               g_hash_table_insert(mimeinfo->typeparameters,
-                                           g_strdup("charset"),
-                                           g_strdup(conv_get_locale_charset_str()));
-                       else
-                               g_hash_table_insert(mimeinfo->typeparameters,
-                                           g_strdup("charset"),
-                                           g_strdup(CS_ISO_8859_1));
+                       g_hash_table_insert(mimeinfo->typeparameters,
+                                   g_strdup("charset"),
+                                   g_strdup(
+                                       conv_get_locale_charset_str_no_utf8()));
                }
        }