Add PHP5-style constructor
[squirrelmail.git] / functions / attachment_common.php
index 35038eeb55d1d3fc5c3f022d7a198ca1a571a68e..4898b083cc19f68fbfc5e4dd54f8fd9684bdde7c 100644 (file)
@@ -5,7 +5,7 @@
  *
  * This file provides the handling of often-used attachment types.
  *
- * @copyright © 1999-2009 The SquirrelMail Project Team
+ * @copyright 1999-2016 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -147,7 +147,7 @@ function attachment_common_link_text(&$Args) {
        $Args[0]['attachment_common']['href'] = Where it links to */
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
 
-    // if htmlspecialchars() breaks something - find other way to encode & in url.
+    // if sm_encode_html_special_chars() breaks something - find other way to encode & in url.
     $Args[0]['attachment_common']['href'] = $base_uri  . 'src/view_text.php?'. $QUERY_STRING;
     $Args[0]['attachment_common']['href'] =
           set_url_var($Args[0]['attachment_common']['href'],
@@ -223,7 +223,7 @@ function attachment_common_link_image(&$Args) {
     
     $attachment_common_show_images_list[] = $info;
 
-    $Args[0]['attachment_common']['href'] = $base_uri  . 'src/image.php?'. htmlspecialchars($QUERY_STRING);
+    $Args[0]['attachment_common']['href'] = $base_uri  . 'src/image.php?'. $QUERY_STRING;
     $Args[0]['attachment_common']['href'] =
           set_url_var($Args[0]['attachment_common']['href'],
           'ent_id',$Args[4]);
@@ -242,7 +242,7 @@ function attachment_common_link_vcard(&$Args) {
     global $base_uri;
     sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
 
-    $Args[0]['attachment_common']['href'] = $base_uri  . 'src/vcard.php?'. htmlspecialchars($QUERY_STRING);
+    $Args[0]['attachment_common']['href'] = $base_uri  . 'src/vcard.php?'. $QUERY_STRING;
     $Args[0]['attachment_common']['href'] =
           set_url_var($Args[0]['attachment_common']['href'],
           'ent_id',$Args[4]);
@@ -265,9 +265,13 @@ function attachment_common_octet_stream(&$Args) {
 //FIXME: or at least we can move this hook up to the top of this file where $FileExtensionToMimeType is defined.  What else is this hook here for?  What plugins use it?
     do_hook('attachment_common-load_mime_types', $null);
 
-    ereg('\\.([^\\.]+)$', $Args[6], $Regs);
+    preg_match('/\.([^.]+)$/', $Args[7], $Regs);
 
-    $Ext = strtolower($Regs[1]);
+    $Ext = '';
+    if (is_array($Regs) && isset($Regs[1])) {
+        $Ext = $Regs[1];
+        $Ext = strtolower($Regs[1]);
+    }
 
     if ($Ext == '' || ! isset($FileExtensionToMimeType[$Ext]))
         return;