xeoncross / forumfive

A < 10kB forum system in PHP - Code Golf
164 stars 18 forks source link

Allow for embedding of pictures from all websites #10

Open s4ke opened 8 years ago

s4ke commented 8 years ago

Currently embedding only works for youtube and vimeo. I guess that was implemented to work for videos only. A simple check while puryfing would help:

if($html->nodeName != 'img' && $attribute->name == 'src') {
    $domain = parse_url($value, PHP_URL_HOST);
    // Only EVER allow embeds from Youtube / Vimeo
    if( ! $domain OR ! in_array($domain, static::$video_sites)) {
        $html->removeAttributeNode($attribute);
    }
    continue;
}