diff options
author | fabrixxm <fabrix.xm@gmail.com> | 2011-11-17 04:53:22 -0800 |
---|---|---|
committer | fabrixxm <fabrix.xm@gmail.com> | 2011-11-17 04:53:22 -0800 |
commit | 32f17e7e24d52bed1b5a5d8ed01d101522b26a9f (patch) | |
tree | 3ba5f23865643ff8c660fb9c9a9eeb44327b8a1b /include/oembed.php | |
parent | c9846b745dfe2a4c20ffe4e1f48bb18da3886fd4 (diff) | |
parent | 844a36e2b6c9cd8e934b57b7d56b7a9863f12929 (diff) | |
download | volse-hubzilla-32f17e7e24d52bed1b5a5d8ed01d101522b26a9f.tar.gz volse-hubzilla-32f17e7e24d52bed1b5a5d8ed01d101522b26a9f.tar.bz2 volse-hubzilla-32f17e7e24d52bed1b5a5d8ed01d101522b26a9f.zip |
Merge pull request #7 from fabrixxm/master
Fix possibile fatal error with oembed
Diffstat (limited to 'include/oembed.php')
-rw-r--r-- | include/oembed.php | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/include/oembed.php b/include/oembed.php index 7c0da4594..118f7fa4a 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -13,24 +13,30 @@ function oembed_replacecb($matches){ function oembed_fetch_url($embedurl){ $txt = Cache::get($embedurl); + + $noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm"); + $ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION); + if(is_null($txt)){ $txt = ""; - // try oembed autodiscovery - $redirects = 0; - $html_text = fetch_url($embedurl, false, $redirects, 15); - if($html_text){ - $dom = @DOMDocument::loadHTML($html_text); - if ($dom){ - $xpath = new DOMXPath($dom); - $attr = "oembed"; - - $xattr = oe_build_xpath("class","oembed"); - $entries = $xpath->query("//link[@type='application/json+oembed']"); - foreach($entries as $e){ - $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href); + if (!in_array($ext, $noexts)){ + // try oembed autodiscovery + $redirects = 0; + $html_text = fetch_url($embedurl, false, $redirects, 15, "text/*"); + if($html_text){ + $dom = @DOMDocument::loadHTML($html_text); + if ($dom){ + $xpath = new DOMXPath($dom); + $attr = "oembed"; + + $xattr = oe_build_xpath("class","oembed"); + $entries = $xpath->query("//link[@type='application/json+oembed']"); + foreach($entries as $e){ + $href = $e->getAttributeNode("href")->nodeValue; + $txt = fetch_url($href); + } } } } |