From e5af2fe88e3282aacbc2c48be5405c1de62df8a2 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 19 Sep 2008 13:11:22 -0400
Subject: [PATCH] Create valid <a> tags

---
 program/steps/mail/func.inc |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 49dfe5f..5676757 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -977,23 +977,26 @@
  * parse link attributes and set correct target
  */
 function rcmail_alter_html_link($tag, $attrs, $container_id)
-  {
+{
   $attrib = parse_attrib_string($attrs);
+  $end = '>';
 
-  if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href']))
+  if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href'])) {
     $attrib['href'] = "./bin/modcss.php?u=" . urlencode($attrib['href']) . "&amp;c=" . urlencode($container_id);
-
-  else if (stristr((string)$attrib['href'], 'mailto:'))
+    $end = ' />';
+  }
+  else if (stristr((string)$attrib['href'], 'mailto:')) {
     $attrib['onclick'] = sprintf(
       "return %s.command('compose','%s',this)",
       JS_OBJECT_NAME,
       JQ(substr($attrib['href'], 7)));
-
-  else if (!empty($attrib['href']) && $attrib['href']{0}!='#')
-    $attrib['target'] = '_blank';
-
-  return "<$tag" . create_attrib_string($attrib, array('href','name','target','onclick','id','class','style','title','rel','type','media')) . ' />';
   }
+  else if (!empty($attrib['href']) && $attrib['href'][0] != '#') {
+    $attrib['target'] = '_blank';
+  }
+
+  return "<$tag" . html::attrib_string($attrib, array('href','name','target','onclick','id','class','style','title','rel','type','media')) . $end;
+}
 
 
 /**

--
Gitblit v1.9.1