From 9711f02db75006d622d75142d46c3c8d714c957f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 28 Feb 2016 21:34:54 +0100 Subject: SimplePie Force HTTPS custom list domains Load from data/force-https.default.txt and data/force-https.txt Efficient tree structure to search the domains https://github.com/FreshRSS/FreshRSS/pull/1087 --- data/force-https.default.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 data/force-https.default.txt (limited to 'data/force-https.default.txt') diff --git a/data/force-https.default.txt b/data/force-https.default.txt new file mode 100644 index 000000000..a1bddd549 --- /dev/null +++ b/data/force-https.default.txt @@ -0,0 +1,4 @@ +dailymotion.com +feedburner.com +tumblr.com +youtube.com -- cgit v1.2.3 From d344da59fdd2f818f53c6b4aab4ded4a9336851c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 29 Feb 2016 17:09:44 +0100 Subject: HTTPS search tree: simplify code https://github.com/FreshRSS/FreshRSS/issues/1083 --- data/force-https.default.txt | 2 ++ lib/SimplePie/SimplePie/Sanitize.php | 58 ++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 32 deletions(-) (limited to 'data/force-https.default.txt') diff --git a/data/force-https.default.txt b/data/force-https.default.txt index a1bddd549..668a7c0e8 100644 --- a/data/force-https.default.txt +++ b/data/force-https.default.txt @@ -1,4 +1,6 @@ dailymotion.com feedburner.com +gstatic.com tumblr.com +wordpress.com youtube.com diff --git a/lib/SimplePie/SimplePie/Sanitize.php b/lib/SimplePie/SimplePie/Sanitize.php index b37aeec3d..f656909a0 100644 --- a/lib/SimplePie/SimplePie/Sanitize.php +++ b/lib/SimplePie/SimplePie/Sanitize.php @@ -263,23 +263,20 @@ class SimplePie_Sanitize { $domain = trim($domain, ". \t\n\r\0\x0B"); $segments = array_reverse(explode('.', $domain)); - if (count($segments) > 0) - { - $node =& $this->https_domains; - foreach ($segments as $segment) - {//Build a tree - if ($node === true) - { - break; - } - if (!isset($node[$segment])) - { - $node[$segment] = array(); - } - $node =& $node[$segment]; + $node =& $this->https_domains; + foreach ($segments as $segment) + {//Build a tree + if ($node === true) + { + break; + } + if (!isset($node[$segment])) + { + $node[$segment] = array(); } - $node = true; + $node =& $node[$segment]; } + $node = true; } } @@ -291,23 +288,20 @@ class SimplePie_Sanitize { $domain = trim($domain, '. '); $segments = array_reverse(explode('.', $domain)); - if (count($segments) > 0) - { - $node =& $this->https_domains; - foreach ($segments as $segment) - {//Explore the tree - if ($node === true) - { - return true; - } - if (isset($node[$segment])) - { - $node =& $node[$segment]; - } - else - { - break; - } + $node =& $this->https_domains; + foreach ($segments as $segment) + {//Explore the tree + if ($node === true) + { + return true; + } + if (isset($node[$segment])) + { + $node =& $node[$segment]; + } + else + { + break; } } return false; -- cgit v1.2.3