Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Commit

Permalink
fix(embed): only allow iframe, video and audio tags in embed html
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
hypeJunction committed Oct 14, 2016
1 parent ebed75f commit cd23401
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 21 additions & 1 deletion classes/hypeJunction/Scraper/Views.php
Expand Up @@ -137,7 +137,7 @@ public static function addBookmarkProfilePreview($hook, $type, $return, $params)
* Linkify longtext output
*
* @param string $hook "view"
* @param string $type "output/longtext""
* @param string $type "output/longtext"
* @param array $return View vars
* @param array $params Hook params
* @return array
Expand All @@ -149,4 +149,24 @@ public static function linkifyLongtext($hook, $type, $return, $params) {
return hypeapps_linkify_tokens($return, $params['vars']);
}

/**
* Filter parsed metatags
*
* @param string $hook "parse"
* @param string $type "framework/scraper"
* @param array $return Data
* @param array $params Hook params
* @return array
*/
public static function cleanEmbedHTML($hook, $type, $return, $params) {

if (!empty($return['html'])) {
// only allow iframe, video, and audio tags
if (!preg_match('/<iframe|video|audio/i', $return['html'])) {
unset($return['html']);
}
}

return $return;
}
}
2 changes: 2 additions & 0 deletions start.php
Expand Up @@ -30,6 +30,8 @@
}

elgg_register_plugin_hook_handler('view', 'output/longtext', [Views::class, 'linkifyLongtext']);

elgg_register_plugin_hook_handler('parse', 'framework:scraper', [Views::class, 'cleanEmbedHTML']);

});

Expand Down

0 comments on commit cd23401

Please sign in to comment.