]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Merge pull request #532 from ArthurHoaro/hotfix/title-retrieve-the-return
[github/shaarli/Shaarli.git] / index.php
index 456d93c24ccd920ee284cac6d988da174703ec82..e9b0bf4058e52f9843a9ecfd3408211abe3724b3 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1519,7 +1519,7 @@ function renderPage()
 
     // -------- User want to post a new link: Display link edit form.
     if (isset($_GET['post'])) {
-        $url = cleanup_url(escape($_GET['post']));
+        $url = cleanup_url($_GET['post']);
 
         $link_is_new = false;
         // Check if URL is not already in database (in this case, we will edit the existing link)
@@ -1544,8 +1544,8 @@ function renderPage()
                     // Extract title.
                     $title = html_extract_title($content);
                     // Re-encode title in utf-8 if necessary.
-                    if (! empty($title) && $charset != 'utf-8') {
-                        $title = mb_convert_encoding($title, $charset, 'utf-8');
+                    if (! empty($title) && strtolower($charset) != 'utf-8') {
+                        $title = mb_convert_encoding($title, 'utf-8', $charset);
                     }
                 }
             }
@@ -1554,6 +1554,8 @@ function renderPage()
                 $url = '?' . smallHash($linkdate);
                 $title = 'Note: ';
             }
+            $url = escape($url);
+            $title = escape($title);
 
             $link = array(
                 'linkdate' => $linkdate,