Skip to content
Permalink
Browse files Browse the repository at this point in the history
RSS: Some URl manipulations
(cherry picked from commit feaa3d4)
  • Loading branch information
mjansenDatabay committed May 11, 2018
1 parent 6b2217c commit d0dcad1
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Services/Feeds/classes/class.ilExternalFeedItem.php
Expand Up @@ -86,23 +86,19 @@ function setMagpieItem($a_item)
function secureString($a_str)
{
$a_str = ilUtil::secureString($a_str, true, "<b><i><em><strong><br><ol><li><ul><a><img>");
$old_str = "";


// set target to blank for all links
while($old_str != $a_str)
{
$old_str = $a_str;
$a_str = preg_replace_callback(
'/<a href=["\']([^\"]*)["\']>/i',
function($matches) {
return sprintf(
'<a href="%s" target="_blank" rel="noopener">',
\ilUtil::secureUrl($matches[1])
);
},
$a_str
);
}
$a_str = preg_replace_callback(
'/<a[^>]*?href=["\']([^"\']*)["\'][^>]*?>/i',
function($matches) {
return sprintf(
'<a href="%s" target="_blank" rel="noopener">',
\ilUtil::secureUrl($matches[1])
);
},
$a_str
);

return $a_str;
}

Expand Down

0 comments on commit d0dcad1

Please sign in to comment.