diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index a95c08cd5..257539b07 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -340,6 +340,8 @@ function html2bbcode($message, $basepath = '')
*/
function addHostnameSub($matches, $basepath) {
$base = parse_url($basepath);
+ unset($base['query']);
+ unset($base['fragment']);
$link = $matches[0];
$url = $matches[1];