From: ArthurHoaro Date: Tue, 8 Mar 2016 09:00:53 +0000 (+0100) Subject: Fixes #512: retrieving title didn't match the first closing tag X-Git-Tag: v0.7.0~25^2 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=68ea1d2b30db8ab295e47e9ac5f6c8e81676caf7 Fixes #512: retrieving title didn't match the first closing tag --- 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; 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 $title = 'Read me please.'; $html = 'stuff'. $title .''; $this->assertEquals($title, html_extract_title($html)); + $html = ''. $title .'blablaanother'; + $this->assertEquals($title, html_extract_title($html)); } /**