Hi all,

This patch fixes the Content-ID header when a 'listed' web programming language is used to get the content (to get an image/sound/video into a DB from a php script for example).


This also fixes the content_type2file_ext() function when Content-type
is populated with more than one values.
(We take the first one expecting the content type)
(eg:  Content-Type: text/plain; charset=utf-8; name="txt1.txt")


Vincent.


--
Telemaque - 06560 SOPHIA-ANTIPOLIS - (FR)
Service Technique/Reseau - NOC
Direction du Developpement xMS+
http://www.telemaque.fr/
[EMAIL PROTECTED]
Tel : +33 4 92 90 99 84 (fax 9142)
diff -rbau /mbuni-cvs/mmlib/mms_util.c /mbuni/mmlib/mms_util.c
--- /mbuni-cvs/mmlib/mms_util.c 2008-08-07 16:09:25.000000000 +0200
+++ /mbuni/mmlib/mms_util.c     2008-08-18 15:53:58.000000000 +0200
@@ -1364,6 +1364,23 @@
      {NULL, NULL}
 };
 
+/* Some of Web languages used for generating content, but can't be a content 
itself. */
+static struct {
+     char *language, *file_ext; }
+l_exts[] = {
+      {"Perl", "pl"},
+      {"Php", "php"},
+      {"Python", "py"},
+      {"Common Gateway Interface", "cgi"},
+      {"Active Server Page", "asp"},
+      {"Java Server Page", "jsp"},
+      {"Ruby on Rails", "rb"},            
+      {"Tool Command Language", "tcl"},      
+      {"Shell Command Language", "sh"},
+      {"Executables", "exe"},
+      {NULL, NULL}
+};
+
 Octstr *filename2content_type(char *fname)
 {
      char *p = strrchr(fname, '.');
@@ -1379,7 +1396,12 @@
 
 static char *content_type2file_ext(Octstr *ctype)
 {
-     int i;     
+     int i,j;     
+
+     /* Take the first value, expecting content-type! */
+     if ((j = octstr_search_char(ctype, ';', 0)) != -1)
+         octstr_delete(ctype, j, octstr_len(ctype));
+
      for (i = 0; exts[i].file_ext; i++)
          if (octstr_str_case_compare(ctype, exts[i].ctype) == 0)
            return exts[i].file_ext;
@@ -1389,6 +1411,7 @@
 
 char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5])
 {
+     int i;
      fext[0] = 0;
      if (url) {
          HTTPURLParse *h = parse_url(url);       
@@ -1402,6 +1425,11 @@
               strncpy(fext, p+1, 4); /* max length of 4. */
          
          http_urlparse_destroy(h);
+        
+          for (i = 0; l_exts[i].file_ext; i++)
+               if (strcasecmp(fext, l_exts[i].file_ext) == 0)
+                    return content_type2file_ext(ctype);
+ 
          if (fext[0]) return fext;
      } 
  done:
_______________________________________________
Devel mailing list
Devel@mbuni.org
http://lists.mbuni.org/mailman/listinfo/devel

Reply via email to