X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fpoche%2FUrl.class.php;h=3c74fb434bb1b7f14cd0f0934874893c44cb578c;hb=fd99a8c02d7c625771656a5c5081560027d8e6e9;hp=f4a8f99e6377dee187142db7495227f8a49860c1;hpb=01c0e050ad8eca54f115dfa21db99e4f61ab7ca7;p=github%2Fwallabag%2Fwallabag.git diff --git a/inc/poche/Url.class.php b/inc/poche/Url.class.php index f4a8f99e..3c74fb43 100644 --- a/inc/poche/Url.class.php +++ b/inc/poche/Url.class.php @@ -27,7 +27,7 @@ class Url public function isCorrect() { - $pattern = '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i'; + $pattern = '|^(.*:)//([a-z\-.]+)(:[0-9]+)?(.*)$|i'; return preg_match($pattern, $this->url); } @@ -64,8 +64,16 @@ class Url if (function_exists('tidy_parse_string')) { $tidy = tidy_parse_string($html, array(), 'UTF8'); $tidy->cleanRepair(); - $html = $tidy->value; - } + + //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; + } + } $parameters = array(); if (isset($html) and strlen($html) > 0) @@ -77,7 +85,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;