From 912d2e35e9f348f3d0bb2431c40d5cd2ba804842 Mon Sep 17 00:00:00 2001 From: zPlus <--> Date: Sun, 13 Nov 2016 06:28:57 +0100 Subject: [PATCH] Remove 'http://' prefix from empty links --- submit.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/submit.php b/submit.php index 58ccda94..06d3e958 100644 --- a/submit.php +++ b/submit.php @@ -35,9 +35,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') // Normalize Link $link = trim ($_POST['link']); - $link_components = parse_url ($link); - if (!isset ($link_components['scheme'])) - $link = 'http://' . $link; + + // If no link given, keep an empty string + if (strlen ($link) > 0) + { + $link_components = parse_url ($link); + + // Make sure there's a "scheme" + if (!isset ($link_components['scheme'])) + $link = 'http://' . $link; + } // Add the new post $post_hash_id = $db->new_post ($title, $link, $_POST['text'], Session::get_userid());