aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-21 17:44:04 -0700
committerredmatrix <git@macgirvin.com>2016-07-21 17:44:04 -0700
commit8566f9130395ecdbe19f9fce85a26dac39d9fe24 (patch)
treeee1905b870485af75a9aaf80cdef6295ae72c6c5 /include
parentb63aff77dffbdea090d60218266f8eae97357299 (diff)
downloadvolse-hubzilla-8566f9130395ecdbe19f9fce85a26dac39d9fe24.tar.gz
volse-hubzilla-8566f9130395ecdbe19f9fce85a26dac39d9fe24.tar.bz2
volse-hubzilla-8566f9130395ecdbe19f9fce85a26dac39d9fe24.zip
fail oembed if it is attempted and less than 80% of the original content is left after html filtering. For the original poster, this will fall back to linkinfo results. If the embed gets through their site but is filtered downstream (with more than 20% of the content removed), it will result in just a link.
Diffstat (limited to 'include')
-rwxr-xr-xinclude/oembed.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/oembed.php b/include/oembed.php
index fe068278e..fe3a3c33c 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -215,6 +215,17 @@ function oembed_fetch_url($embedurl){
if($j->html != $orig) {
logger('oembed html was purified. original: ' . $orig . ' purified: ' . $j->html, LOGGER_DEBUG, LOG_INFO);
}
+
+ $orig_len = trim(mb_strlen($orig));
+ $new_len = trim(mb_strlen($j->html));
+ if(! $new_len)
+ $j->type = 'error';
+ elseif($orig_len) {
+ $ratio = $new_len / $orig_len;
+ if($ratio < 0.8)
+ $j->type = 'error';
+ }
+
}
}