aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2016-03-14 21:29:19 +0100
committerVirtualTam <virtualtam@flibidi.net>2016-03-14 21:29:19 +0100
commit5816801b15e1a0e53f87aa48267243bff44b5f64 (patch)
tree3be406a48569c02a17584de99982dedd25627830
parent890afc32f744859d11b97eb26ed5c030af9b4145 (diff)
parent68ea1d2b30db8ab295e47e9ac5f6c8e81676caf7 (diff)
downloadShaarli-5816801b15e1a0e53f87aa48267243bff44b5f64.tar.gz
Shaarli-5816801b15e1a0e53f87aa48267243bff44b5f64.tar.zst
Shaarli-5816801b15e1a0e53f87aa48267243bff44b5f64.zip
Merge pull request #513 from ArthurHoaro/hotfix/retrieve-title-issue
Fixes #512: retrieving title didn't match the first closing tag
-rw-r--r--application/LinkUtils.php2
-rw-r--r--tests/LinkUtilsTest.php2
2 files changed, 3 insertions, 1 deletions
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 @@
9 */ 9 */
10function html_extract_title($html) 10function html_extract_title($html)
11{ 11{
12 if (preg_match('!<title>(.*)</title>!is', $html, $matches)) { 12 if (preg_match('!<title>(.*?)</title>!is', $html, $matches)) {
13 return trim(str_replace("\n", ' ', $matches[1])); 13 return trim(str_replace("\n", ' ', $matches[1]));
14 } 14 }
15 return false; 15 return false;
diff --git a/tests/LinkUtilsTest.php b/tests/LinkUtilsTest.php
index c2257590..609a80cb 100644
--- a/tests/LinkUtilsTest.php
+++ b/tests/LinkUtilsTest.php
@@ -15,6 +15,8 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase
15 $title = 'Read me please.'; 15 $title = 'Read me please.';
16 $html = '<html><meta>stuff</meta><title>'. $title .'</title></html>'; 16 $html = '<html><meta>stuff</meta><title>'. $title .'</title></html>';
17 $this->assertEquals($title, html_extract_title($html)); 17 $this->assertEquals($title, html_extract_title($html));
18 $html = '<html><title>'. $title .'</title>blabla<title>another</title></html>';
19 $this->assertEquals($title, html_extract_title($html));
18 } 20 }
19 21
20 /** 22 /**