]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Fixes #531 - Title retrieving is failing with multiple use case
[github/shaarli/Shaarli.git] / index.php
index dfc00fbd6c5d437ef8e074494e7443f7f0067673..41a42cf6736b95ba60a45e71e322ace7bb56c0a0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1516,7 +1516,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)
@@ -1541,8 +1541,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);
                     }
                 }
             }
@@ -1551,6 +1551,8 @@ function renderPage()
                 $url = '?' . smallHash($linkdate);
                 $title = 'Note: ';
             }
+            $url = escape($url);
+            $title = escape($title);
 
             $link = array(
                 'linkdate' => $linkdate,