Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Preserve Redirection Links for Images in Emails #18397

Open
wants to merge 2 commits into
base: 10.0/bugfixes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpunit/functional/ToolboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ public function testConvertTagToImageAlreadyInLink()
$expected_result = <<<HTML
Some contents with <a href="http://example.org/">a link</a>
and a first image <a href="{$expected_url_1}" target="_blank"><img alt="{$img_1_tag}" width="10" src="{$image_1_src}" /></a> inside a link
then a second image surrounded by links <a href="http://www.example.org/">link1</a> <a href="{$image_2_src}" target="_blank" ><img alt="{$img_2_tag}" width="10" src="{$image_2_src}" /></a> <a href="http://www.example.org/2">link2</a>
then a second image surrounded by links <a href="http://www.example.org/">link1</a> <img alt="{$img_2_tag}" width="10" src="{$image_2_src}" /> <a href="http://www.example.org/2">link2</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
then a second image surrounded by links <a href="http://www.example.org/">link1</a> <img alt="{$img_2_tag}" width="10" src="{$image_2_src}" /> <a href="http://www.example.org/2">link2</a>
then a second image surrounded by links <a href="http://www.example.org/">link1</a> <a href="{$image_2_src}" target="_blank" ><img alt="{$img_2_tag}" width="10" src="{$image_2_src}" /></a> <a href="http://www.example.org/2">link2</a>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep original test

HTML;

$docs_data = [
Expand Down
2 changes: 1 addition & 1 deletion src/Toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -2815,7 +2815,7 @@ public static function convertTagToImage($content_text, CommonDBTM $item, $doc_d
// Avoids creating a link within a link, when the image is already in an <a> tag
$add_link_tmp = $add_link;
if ($add_link) {
$pattern = '/<a[^>]*>[^<>]*?<img[^>]+' . preg_quote($image['tag'], '/') . '[^<]+>[^<>]*?<\/a>/s';
$pattern = '/<a[^>]*>.*?<img[^>]*' . preg_quote($image['tag'], '/') . '[^>]*>.*?<\/a>/s';
if (preg_match($pattern, $content_text)) {
$add_link_tmp = false;
}
Expand Down