From fe79b1bcf828b6b9f947c4b32d5e7bf297438be4 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 30 Jul 2006 06:14:19 -0400
Subject: [PATCH] Alter links in HTML messages; highlight droptargets

---
 program/include/main.inc |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index e77df19..bbfba07 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -541,12 +541,14 @@
 
   if ($user_id = $DB->insert_id(get_sequence_name('users')))
     {
-    if (is_array($CONFIG['mail_domain']) && isset($CONFIG['mail_domain'][$host]))
-      $mail_domain = $CONFIG['mail_domain'][$host];
+    $mail_domain = $host;
+    if (is_array($CONFIG['mail_domain']))
+      {
+      if (isset($CONFIG['mail_domain'][$host]))
+        $mail_domain = $CONFIG['mail_domain'][$host];
+      }
     else if (!empty($CONFIG['mail_domain']))
       $mail_domain = $CONFIG['mail_domain'];
-    else
-      $mail_domain = $host;
    
     if ($user_email=='')
       $user_email = strstr($user, '@') ? $user : sprintf('%s@%s', $user, $mail_domain);
@@ -1125,21 +1127,12 @@
   }
 
 
-function rcube_xml_command($command, $str_attrib, $a_attrib=NULL)
+function rcube_xml_command($command, $str_attrib, $add_attrib=array())
   {
   global $IMAP, $CONFIG, $OUTPUT;
   
-  $attrib = array();
   $command = strtolower($command);
-
-  preg_match_all('/\s*([-_a-z]+)=["]([^"]+)["]?/i', stripslashes($str_attrib), $regs, PREG_SET_ORDER);
-
-  // convert attributes to an associative array (name => value)
-  if ($regs)
-    foreach ($regs as $attr)
-      $attrib[strtolower($attr[1])] = $attr[2];
-  else if ($a_attrib)
-    $attrib = $a_attrib;
+  $attrib = parse_attrib_string($str_attrib) + $add_attrib;
 
   // execute command
   switch ($command)
@@ -1223,7 +1216,7 @@
         'identityform' => 'rcube_identity_form',
         'foldersubscription' => 'rcube_subscription_form',
         'createfolder' => 'rcube_create_folder_form',
-	'renamefolder' => 'rcube_rename_folder_form',
+        'renamefolder' => 'rcube_rename_folder_form',
         'composebody' => 'rcmail_compose_body'
       );
 
@@ -1523,18 +1516,33 @@
   }
 
 
+// compose a valid attribute string for HTML tags
 function create_attrib_string($attrib, $allowed_attribs=array('id', 'class', 'style'))
   {
   // allow the following attributes to be added to the <iframe> tag
   $attrib_str = '';
   foreach ($allowed_attribs as $a)
     if (isset($attrib[$a]))
-      $attrib_str .= sprintf(' %s="%s"', $a, $attrib[$a]);
+      $attrib_str .= sprintf(' %s="%s"', $a, str_replace('"', '&quot;', $attrib[$a]));
 
   return $attrib_str;
   }
 
 
+// convert a HTML attribute string attributes to an associative array (name => value)
+function parse_attrib_string($str)
+  {
+  $attrib = array();
+  preg_match_all('/\s*([-_a-z]+)=["]([^"]+)["]?/i', stripslashes($str), $regs, PREG_SET_ORDER);
+
+  // convert attributes to an associative array (name => value)
+  if ($regs)
+    foreach ($regs as $attr)
+      $attrib[strtolower($attr[1])] = $attr[2];
+
+  return $attrib;
+  }
+
 
 function format_date($date, $format=NULL)
   {

--
Gitblit v1.9.1