X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=ac51038d7f1f50e940a2a6ad66aa3806dff742b7;hb=d65342e304f92643ba922200953cfebc51e1e482;hp=fb00a9fa3adb8d302f712fcbe7d7fc2a694409f4;hpb=a59bbf50d7530d7e82a91896a210b9da49cb1568;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index fb00a9fa..ac51038d 100644 --- a/index.php +++ b/index.php @@ -1428,16 +1428,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) // If this is an HTTP(S) link, we try go get the page to extract the title (otherwise we will to straight to the edit form.) if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { // Short timeout to keep the application responsive - list($headers, $content) = get_http_response($url, 4); - if (strpos($headers[0], '200 OK') !== false) { - // Retrieve charset. - $charset = get_charset($headers, $content); - // Extract title. - $title = html_extract_title($content); - // Re-encode title in utf-8 if necessary. - if (! empty($title) && strtolower($charset) != 'utf-8') { - $title = mb_convert_encoding($title, 'utf-8', $charset); - } + // The callback will fill $charset and $title with data from the downloaded page. + get_http_response($url, 25, 4194304, get_curl_download_callback($charset, $title)); + if (! empty($title) && strtolower($charset) != 'utf-8') { + $title = mb_convert_encoding($title, 'utf-8', $charset); } }