From 68ea1d2b30db8ab295e47e9ac5f6c8e81676caf7 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 8 Mar 2016 10:00:53 +0100 Subject: Fixes #512: retrieving title didn't match the first closing tag --- application/LinkUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/LinkUtils.php') diff --git a/application/LinkUtils.php b/application/LinkUtils.php index 26dd6b67..d8dc8b5e 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php @@ -9,7 +9,7 @@ */ function html_extract_title($html) { - if (preg_match('!(.*)!is', $html, $matches)) { + if (preg_match('!(.*?)!is', $html, $matches)) { return trim(str_replace("\n", ' ', $matches[1])); } return false; -- cgit v1.2.3 From ce7b0b6480aa854ee6893f5c889277b0e3b13efc Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 6 Apr 2016 22:00:52 +0200 Subject: Fixes #531 - Title retrieving is failing with multiple use case see https://github.com/shaarli/Shaarli/issues/531 for details --- application/LinkUtils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'application/LinkUtils.php') diff --git a/application/LinkUtils.php b/application/LinkUtils.php index d8dc8b5e..2df76ba8 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php @@ -9,8 +9,8 @@ */ function html_extract_title($html) { - if (preg_match('!(.*?)!is', $html, $matches)) { - return trim(str_replace("\n", ' ', $matches[1])); + if (preg_match('!(.*?)!is', $html, $matches)) { + return trim(str_replace("\n", '', $matches[1])); } return false; } @@ -70,7 +70,7 @@ function headers_extract_charset($headers) function html_extract_charset($html) { // Get encoding specified in HTML header. - preg_match('#/]+)"? */?>#Usi', $html, $enc); + preg_match('#/]+)["\']? */?>#Usi', $html, $enc); if (!empty($enc[1])) { return strtolower($enc[1]); } -- cgit v1.2.3 From 141a86c503af8e314381b3ee39ba4287fdfac63e Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 11 May 2016 00:05:22 +0200 Subject: Add private link counter --- application/LinkUtils.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'application/LinkUtils.php') diff --git a/application/LinkUtils.php b/application/LinkUtils.php index 2df76ba8..da04ca97 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php @@ -77,3 +77,19 @@ function html_extract_charset($html) return false; } + +/** + * Count private links in given linklist. + * + * @param array $links Linklist. + * + * @return int Number of private links. + */ +function count_private($links) +{ + $cpt = 0; + foreach ($links as $link) { + $cpt = $link['private'] == true ? $cpt + 1 : $cpt; + } + return $cpt; +} -- cgit v1.2.3