PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #6568

Mail_Mime: inline images referenced in CSS definitions not replaced.

Details

Request #6568Mail_Mime: inline images referenced in CSS definitions not replaced.
Submitted2006-01-24 16:11 UTC
Frommarcus dot mueller at grintsch dot com
Assignedcipri
StatusClosed
PackageMail_Mime
PHP VersionIrrelevant
OSIrrelevant
Roadmaps1.4.0, 1.4.0a1

Comments

[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';

[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.