Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Request #6568 Mail_Mime: inline images referenced in CSS definitions not replaced.
Submitted: 2006-01-24 16:11 UTC
From: marcus dot mueller at grintsch dot com Assigned: cipri
Status: Closed Package: Mail_Mime
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: 1.4.0, 1.4.0a1    
Subscription  


 [2006-01-24 16:11 UTC] marcus dot mueller at grintsch dot com
Description: ------------ Mail_Mime's get() method contains a regular expression which is meant to replace occurences of an attached inline image file's name within attached HTML source code. While the method works well for HTML attributes like src, href or background it fails to replace occurences within CSS declarations that use the url() pattern, e.g. <img style="background-image:url(myPic.png);"> One might argue that most mail clients don't support CSS background-images anyway but I felt that for sake of "completeness" and the few clients that do support it the replacement code below might be useful. Please do note that I'm by no means an expert at regular expressions. Test script: --------------- Regex part in mime.php's get() method // original code $regex = '#(\s)((?i)src|background|href(?-i))\s*=\s*(["\']?)' . preg_quote($value['name'], '#') . '\3#'; $rep = '\1\2=\3cid:' . $value['cid'] .'\3'; // suggested replacement code $regex = '#((?i)src|background|href|url(?-i))(\s*=?\s*|.?)(["\'\(]?)' . preg_quote($value['name'], '#') . '(["\'\)]?)#'; $rep = '\1\2\3cid:'.$value['cid'].'\4'; $rep = '\1\2=\3cid:' . $value['cid'] .'\3';

Comments

 [2006-01-24 16:15 UTC] marcus dot mueller at grintsch dot com
Sorry, I was in a hurry when I submitted the report, so a double assignment to $rep slipped through in my replacement code. Please remove the "$rep = '\1\2=\3cid:' . $value['cid'] .'\3';" part.
 [2006-04-09 00:38 UTC] cipri (Cipriano Groenendal)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. A modified version has been included in mime.php revision 1.46
 [2007-05-05 15:04 UTC] cipri (Cipriano Groenendal)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Mail_Mime Fixed in 1.4.0