Opened 13 years ago
Closed 13 years ago
#19808 closed defect (bug) (fixed)
PHPMailer -> MsgHTML single quote bug
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | minor | Version: | 3.3.1 |
Component: | Keywords: | has-patch close | |
Focuses: | Cc: |
Description
If you pass in the contents of a HTML email to the MsgHTML method of the PHPMailer class it should attach all images to the email and replace the image src with the path to the attached image. If you use double quotes for the image src everything works fine.
<img src="image.png" />
If however you use single quotes (which as far as I'm aware is still part of the HTML spec for valid attributes) then the function doesn't replace any images or attach any of the images to the email like it's suppose to.
The problem is down to two regular expressions that require double quotes. I have created a diff patch to fix those regular expressions, making both single and double quotes valid.
So now both these work:
<img src="image.png" /> and <img src='image.png' />
I'm not sure what the protocol is regarding patches for external modules but thought I would mention the issue here. I have also sent the diff patch to the developer of the class as specified on Google code so if my patch is worthy (needed even) then the update might get into a future release of PHPMailer.
Attachments (2)
Change History (6)
#2
@
13 years ago
- Cc kpayne@… added
Your code would also match: <img src=|image.png| />
The character group (square brackets) already means "any of these characters." You would only use the pipe in a parentheses group. For example: [\"']
is equivalent to (\"|')
Have you tested without the pipe?
Is it a problem that this could would also match imbalanced quotes? This matches:
<img src='image.png" />
and <img src="image.png' />
I would, generally, say not a problem, since the images get re-written using correct markup. Others may want to weigh in on this.
Patch