X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=d57789e656749c248fbffe1e60a862b0aad4fbe6;hb=d449f79a0d7ca808b891baf73b9e25ce7f7e48fe;hp=9d5f25eaf6bddc0b637db9264d9a5305fa72c40e;hpb=fd08b50a80c3aed25f9e2a19cbfe9fb3ad35cf1f;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 9d5f25ea..d57789e6 100644 --- a/index.php +++ b/index.php @@ -436,7 +436,7 @@ if (isset($_POST['login'])) else { ban_loginFailed($conf); - $redir = '&username='. $_POST['login']; + $redir = '&username='. urlencode($_POST['login']); if (isset($_GET['post'])) { $redir .= '&post=' . urlencode($_GET['post']); foreach (array('description', 'source', 'title', 'tags') as $param) { @@ -1425,16 +1425,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager) // 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); } }