Skip to content

Commit b5314d2

Browse files
committed
give less priority to flash codes (<embed> <object>)
1 parent e57f778 commit b5314d2

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/Adapters/Adapter.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,30 @@ public function getSource()
215215
*/
216216
public function getCode()
217217
{
218-
if ($code = Utils::getFirstValue(Utils::getData($this->providers, 'code'))) {
219-
if (strpos($code, '</iframe>') !== false) {
220-
return preg_replace('|^.*(<iframe.*</iframe>).*$|Us', '$1', $code);
221-
}
218+
$allCodes = Utils::getData($this->providers, 'code');
219+
220+
$default = null;
221+
222+
foreach ($allCodes as $codeInfo) {
223+
$code = $codeInfo['value'];
222224

223-
if (strpos($code, '</object>') !== false) {
224-
return preg_replace('|^.*(<object.*</object>).*$|Us', '$1', $code);
225+
// <object> and <embed> codes have less priority
226+
if (strpos($code, '</object>') !== false || strpos($code, '</embed>') !== false) {
227+
if (empty($default)) {
228+
$default = $code;
229+
}
230+
231+
continue;
225232
}
226233

227-
if (strpos($code, '</embed>') !== false) {
228-
return preg_replace('|^.*(<embed.*</embed>).*$|Us', '$1', $code);
234+
if (strpos($code, '</iframe>') !== false) {
235+
return preg_replace('|^.*(<iframe.*</iframe>).*$|Us', '$1', $code);
229236
}
230237

231238
return $code;
232239
}
240+
241+
return $default;
233242
}
234243

235244
/**

0 commit comments

Comments
 (0)