[Tickets #363] NEW: Bug with Horde::img() method
bugs at bugs.horde.org
bugs at bugs.horde.org
Thu Jul 8 01:49:06 PDT 2004
DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.
-Ticket 363
-Queue: Horde Framework
-Created By:
>From nghonwing at yahoo.co.uk (Thu Jul 8 01:49:06 2004):
The current method has two bugs in it when used with IMP which cause invalid
Html to be formed
1, When other attributes are listed after alt tag in the $attr parameter,
they will be duplicated in the resulting html. This is due to an incorrect
regular expression which is missing an '?' to cut down its greediness.
2, 'border="0"' is specified for every call of this method. If the user
wants to override this by their own border attribute value in the $attr
parameter, the original 'border="0"' will still be in the resulting code.
The fix for both these bugs is as follows:
in the file /horde/lib/Horde.php
changed line 590 to 602 function Horde::img from:
$img = '<img';
$img .= ' src="' . (empty($dir) ? '' : $dir . '/') . $src . '"';
$img .= ' border="0"';
if (!empty($attr)) {
$img .= ' ' . $attr;
if (preg_match('/alt=([\'"])([^\1]*)\1/i', $attr, $match)) {
$img .= ' title="'. $match[2] . '"';
}
}
if (empty($attr) || !strstr($attr, 'alt')) {
$img .= ' alt=""';
}
$img .= ' />';
to
$img = '<img';
$img .= ' src="' . (empty($dir) ? '' : $dir . '/') . $src . '"';
if (!empty($attr)) {
$img .= ' ' . $attr;
#note the '?' in the following lines
if (preg_match('/alt=([\'"])([^\1]*?)\1/i', $attr, $match)) {
$img .= ' title="'. $match[2] . '"';
}
if (!preg_match('/border *= *([\'"])([^\1]*?)\1/i', $attr)) {
$img .= ' border="0"';
}
} else {
$img .= ' border="0"';
}
if (empty($attr) || !strstr($attr, 'alt')) {
$img .= ' alt=""';
}
$img .= ' />';
Cheers
Grant
http://bugs.horde.org/details.php?id=363
--
More information about the bugs
mailing list