Skip to content

Commit da839c3

Browse files
committed
Editor: Allow all domain in iframes insertion if setting to allow iframe is true in HTMLPurifier filter - refs BT#22175 BT#22102
1 parent a591c25 commit da839c3

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/Chamilo/CoreBundle/Component/HTMLPurifier/Filter/AllowIframes.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,16 @@ protected function postFilterCallback($matches)
5959
// Domain Whitelist
6060
$hostName = [];
6161
preg_match('#https?://(.*)#i', api_get_path(WEB_PATH), $hostName);
62+
$extra = ' frameborder="0"';
6263

6364
$youTubeMatch = preg_match('#src="(https:)?//www.youtube(-nocookie)?.com/#i', $matches[1]);
6465
$vimeoMatch = preg_match('#://player.vimeo.com/#i', $matches[1]);
65-
$googleMapsMatch = preg_match('#src="https://maps.google.com/#i', $matches[1]);
66-
$slideShare = preg_match('#src="(https?:)?//www.slideshare.net/#', $matches[1]);
67-
$platformDomain = preg_match('#src="https?://(.+\.)?'.$hostName[1].'#i', $matches[1]);
6866

69-
if ($youTubeMatch || $vimeoMatch || $googleMapsMatch || $slideShare || $platformDomain) {
70-
$extra = ' frameborder="0"';
71-
if ($youTubeMatch) {
72-
$extra .= ' allowfullscreen';
73-
} elseif ($vimeoMatch) {
74-
$extra .= ' webkitAllowFullScreen mozallowfullscreen allowFullScreen';
75-
}
76-
77-
return '<iframe '.$matches[1].$extra.'></iframe>';
78-
} else {
79-
return '';
67+
if ($youTubeMatch) {
68+
$extra .= ' allowfullscreen';
69+
} elseif ($vimeoMatch) {
70+
$extra .= ' webkitAllowFullScreen mozallowfullscreen allowFullScreen';
8071
}
72+
return '<iframe '.$matches[1].$extra.'></iframe>';
8173
}
8274
}

0 commit comments

Comments
 (0)