aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-01-23 18:41:38 +0100
committerGitHub <noreply@github.com>2018-01-23 18:41:38 +0100
commitd449f79a0d7ca808b891baf73b9e25ce7f7e48fe (patch)
tree66e40b38bfce1475b745d6a1227f478f8e99ab75 /index.php
parent5f8c3f532ed16ad5b789f75e9ff745e5329271c3 (diff)
parentd65342e304f92643ba922200953cfebc51e1e482 (diff)
downloadShaarli-d449f79a0d7ca808b891baf73b9e25ce7f7e48fe.tar.gz
Shaarli-d449f79a0d7ca808b891baf73b9e25ce7f7e48fe.tar.zst
Shaarli-d449f79a0d7ca808b891baf73b9e25ce7f7e48fe.zip
Merge pull request #977 from ArthurHoaro/feature/dl-filter
Extract the title/charset during page download, and check content type
Diffstat (limited to 'index.php')
-rw-r--r--index.php14
1 files changed, 4 insertions, 10 deletions
diff --git a/index.php b/index.php
index 27335a36..d57789e6 100644
--- a/index.php
+++ b/index.php
@@ -1425,16 +1425,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
1425 // 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.) 1425 // 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.)
1426 if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { 1426 if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) {
1427 // Short timeout to keep the application responsive 1427 // Short timeout to keep the application responsive
1428 list($headers, $content) = get_http_response($url, 4); 1428 // The callback will fill $charset and $title with data from the downloaded page.
1429 if (strpos($headers[0], '200 OK') !== false) { 1429 get_http_response($url, 25, 4194304, get_curl_download_callback($charset, $title));
1430 // Retrieve charset. 1430 if (! empty($title) && strtolower($charset) != 'utf-8') {
1431 $charset = get_charset($headers, $content); 1431 $title = mb_convert_encoding($title, 'utf-8', $charset);
1432 // Extract title.
1433 $title = html_extract_title($content);
1434 // Re-encode title in utf-8 if necessary.
1435 if (! empty($title) && strtolower($charset) != 'utf-8') {
1436 $title = mb_convert_encoding($title, 'utf-8', $charset);
1437 }
1438 } 1432 }
1439 } 1433 }
1440 1434