Skip to content
Snippets Groups Projects
Commit f8b490d0 authored by Jared Hancock's avatar Jared Hancock
Browse files

Relax detection of images for strip detection

It is perfectectly fine to have an image cited in an HTML body similar to:

<img width=909 height=302 src=cid:image002.jpg@01CF5426.BF5A72A0 alt=image>

Which may or may not have quoted @src attribute, and may very well have an
at sign (@) somewhere in the attribute text. The previous regular expression
would not match such a @src attribute.
parent 6b753cac
No related branches found
No related tags found
No related merge requests found
......@@ -1274,7 +1274,7 @@ class ThreadBody /* extends SplString */ {
// Capture a list of inline images
$images_before = $images_after = array();
preg_match_all('/src="cid:([\w_-]+)(?:@|")/', $this->body, $images_before,
preg_match_all('/src=("|\'|\b)cid:(\S+)\1/', $this->body, $images_before,
PREG_PATTERN_ORDER);
// Strip the quoted part of the body
......@@ -1283,10 +1283,10 @@ class ThreadBody /* extends SplString */ {
// Capture a list of dropped inline images
if ($images_before) {
preg_match_all('/src="cid:([\w_-]+)(?:@|")/', $this->body,
preg_match_all('/src=("|\'|\b)cid:(\S+)\1/', $this->body,
$images_after, PREG_PATTERN_ORDER);
$this->stripped_images = array_diff($images_before[1],
$images_after[1]);
$this->stripped_images = array_diff($images_before[2],
$images_after[2]);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment