]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/LinkUtils.php
Merge pull request #532 from ArthurHoaro/hotfix/title-retrieve-the-return
[github/shaarli/Shaarli.git] / application / LinkUtils.php
old mode 100755 (executable)
new mode 100644 (file)
index 26dd6b6..2df76ba
@@ -9,8 +9,8 @@
  */
 function html_extract_title($html)
 {
-    if (preg_match('!<title>(.*)</title>!is', $html, $matches)) {
-        return trim(str_replace("\n", ' ', $matches[1]));
+    if (preg_match('!<title.*?>(.*?)</title>!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('#<meta .*charset="?([^">/]+)"? */?>#Usi', $html, $enc);
+    preg_match('#<meta .*charset=["\']?([^";\'>/]+)["\']? */?>#Usi', $html, $enc);
     if (!empty($enc[1])) {
         return strtolower($enc[1]);
     }