X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=inc%2Fpoche%2FUrl.class.php;h=d7ee911fcbbf5c8287ff72a68edd2d98bdb74ec9;hb=1cbd70639c5f97f6030d0df6624ca200dba86945;hp=77ed53985ac336719999082977d40d4c5cd1cfbc;hpb=64fa45e262d24f75740b0df267bb2fc4cdf83fa2;p=github%2Fwallabag%2Fwallabag.git diff --git a/inc/poche/Url.class.php b/inc/poche/Url.class.php index 77ed5398..d7ee911f 100644 --- a/inc/poche/Url.class.php +++ b/inc/poche/Url.class.php @@ -27,9 +27,7 @@ class Url public function isCorrect() { - $pattern = '|^(.*:)//([a-z\-.]+)(:[0-9]+)?(.*)$|i'; - - return preg_match($pattern, $this->url); + return filter_var($this->url, FILTER_VALIDATE_URL) !== FALSE; } public function clean() @@ -65,14 +63,15 @@ class Url $tidy = tidy_parse_string($html, array(), 'UTF8'); $tidy->cleanRepair(); - //Warning: tidy might fail so, ensure there is still a content - $body = $tidy->body(); + //Warning: tidy might fail so, ensure there is still a content + $body = $tidy->body(); - //hasChildren does not seem to work, just check the string - //returned (and do not forget to clean the white spaces) - if (preg_replace('/\s+/', '', $body->value) !== "") - $html = $tidy->value; - } + //hasChildren does not seem to work, just check the string + //returned (and do not forget to clean the white spaces) + if (preg_replace('/\s+/', '', $body->value) !== "") { + $html = $tidy->value; + } + } $parameters = array(); if (isset($html) and strlen($html) > 0) @@ -84,7 +83,7 @@ class Url if($readability->init()) { $content = $readability->articleContent->innerHTML; - $parameters['title'] = $readability->articleTitle->innerHTML; + $parameters['title'] = ($readability->articleTitle->innerHTML != '' ? $readability->articleTitle->innerHTML : _('Untitled')); $parameters['content'] = $content; return $parameters;