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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2007-05-05 15:04 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!