Skip to content

Commit

Permalink
bug #47329 Email image parts: regex for single closing quote (rr-it)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

Email image parts: regex for single closing quote

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

The regex for image src matches for single and double opening quotes:
`([\'"])`

The corresponding matching for non-closing characters is implemented for double quotes only:
`([^"]+)`

This change adds a non-greedy regex `.+?` which matches for as few characters as possbile before the "correspondingly matched opening quote" `\\1` appears.

Commits
-------

57c49b4 Email image parts: regex for single closing quote
  • Loading branch information
fabpot committed Aug 19, 2022
2 parents d651770 + 57c49b4 commit f91c198
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mime/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ private function prepareParts(): ?array
$html = stream_get_contents($html);
}
$htmlPart = new TextPart($html, $this->htmlCharset, 'html');
preg_match_all('(<img\s+[^>]*src\s*=\s*(?:([\'"])cid:([^"]+)\\1|cid:([^>\s]+)))i', $html, $names);
preg_match_all('(<img\s+[^>]*src\s*=\s*(?:([\'"])cid:(.+?)\\1|cid:([^>\s]+)))i', $html, $names);
$names = array_filter(array_unique(array_merge($names[2], $names[3])));
}

Expand Down

0 comments on commit f91c198

Please sign in to comment.