From ba2853caac636d2ae596d74561fa0233567242d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9my=20DECOOL?= Date: Sun, 12 Feb 2017 11:01:36 +0100 Subject: [PATCH] Prevent target='_blank' vulnerability on dynamic link --- classes/feeds.php | 12 ++++++------ classes/pref/prefs.php | 4 ++-- include/feedbrowser.php | 8 ++++---- include/functions2.php | 20 +++++++++++--------- plugins/af_psql_trgm/init.php | 2 +- plugins/share/init.php | 2 +- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index a4110938..6b96d836 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -398,7 +398,7 @@ class Feeds extends Handler_Protected { alt=\"Publish article\" onclick='togglePub($id)'>"; } -# $content_link = "" . +# $content_link = "" . # $line["title"] . ""; # $content_link = " ". $line["title"] . " $entry_author"; @@ -691,13 +691,13 @@ class Feeds extends Handler_Protected { $tmp_line = $this->dbh->fetch_assoc($tmp_result); - $reply['content'] .= "" . $tmp_line['title'] . ""; $reply['content'] .= " "; - $reply['content'] .= ""; + $reply['content'] .= ""; $reply['content'] .= ""; $reply['content'] .= ""; @@ -746,12 +746,12 @@ class Feeds extends Handler_Protected { $comments_url = htmlspecialchars($line["link"]); } $entry_comments = "$num_comments ". + target='_blank' rel='noopener noreferrer' href=\"$comments_url\">$num_comments ". _ngettext("comment", "comments", $num_comments).""; } else { if ($line["comments"] && $line["link"] != $line["comments"]) { - $entry_comments = "".__("comments").""; + $entry_comments = "".__("comments").""; } } diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 9a7ab55a..ece9e807 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -776,7 +776,7 @@ class Pref_Prefs extends Handler_Protected { print ""; print "" . htmlspecialchars($about[1]); if (@$about[4]) { - print " — ".__("more info").""; } print ""; @@ -835,7 +835,7 @@ class Pref_Prefs extends Handler_Protected { print ""; print ""; if (@$about[4]) { - print " — ".__("more info").""; } print ""; diff --git a/include/feedbrowser.php b/include/feedbrowser.php index 4772420a..ec4efe15 100644 --- a/include/feedbrowser.php +++ b/include/feedbrowser.php @@ -59,12 +59,12 @@ $class = ($feedctr % 2) ? "even" : "odd"; - $site_url = " ". htmlspecialchars($line["title"]).""; - $feed_url = ""; @@ -87,12 +87,12 @@ $archived = ''; } - $site_url = " ". htmlspecialchars($line["title"]).""; - $feed_url = ""; diff --git a/include/functions2.php b/include/functions2.php index d490ae50..96274b6a 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -955,6 +955,7 @@ $a->appendChild(new DOMText($entry->getAttribute('src'))); $a->setAttribute('target', '_blank'); + $a->setAttribute('rel', 'noopener noreferrer'); $p->appendChild($a); @@ -964,6 +965,7 @@ if (strtolower($entry->nodeName) == "a") { $entry->setAttribute("target", "_blank"); + $entry->setAttribute("rel", "noopener noreferrer"); } } @@ -1249,7 +1251,7 @@ "; } - if ($entry) $entry .= "  " . basename($url) . ""; return $entry; @@ -1260,7 +1262,7 @@ /* $filename = substr($url, strrpos($url, "/")+1); - $entry .= " " . + $entry .= " " . $filename . " (" . $ctype . ")" . ""; */ } @@ -1332,12 +1334,12 @@ $comments_url = htmlspecialchars($line["link"]); } $entry_comments = "$num_comments ". + target='_blank' rel=\"noopener noreferrer\" href=\"$comments_url\">$num_comments ". _ngettext("comment", "comments", $num_comments).""; } else { if ($line["comments"] && $line["link"] != $line["comments"]) { - $entry_comments = "".__("comments").""; + $entry_comments = "".__("comments").""; } } @@ -1373,7 +1375,7 @@ $rv['content'] .= "
$parsed_updated
"; if ($line["link"]) { - $rv['content'] .= "
" . @@ -1442,13 +1444,13 @@ $tmp_line = db_fetch_assoc($tmp_result); - $rv['content'] .= "" . $tmp_line['title'] . ""; $rv['content'] .= " "; - $rv['content'] .= ""; + $rv['content'] .= ""; $rv['content'] .= ""; $rv['content'] .= "
"; @@ -1957,7 +1959,7 @@ if ($player) array_push($entries_inline, $player); -# $entry .= " " . +# $entry .= " " . # $filename . " (" . $ctype . ")" . ""; $entry = "

"; } else { - $rv .= "

" .htmlspecialchars($entry["url"]) . "

"; } diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 8c92be1a..542cd720 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -85,7 +85,7 @@ class Af_Psql_Trgm extends Plugin { style='vertical-align : middle'>"; $article_link = htmlspecialchars($line["link"]); - print " ". + print " ". $line["title"].""; print " (". diff --git a/plugins/share/init.php b/plugins/share/init.php index 0f8f8fec..a028c057 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -100,7 +100,7 @@ class Share extends Plugin { $url_path .= "/public.php?op=share&key=$uuid"; print "
"; - print "$url_path"; + print "$url_path"; print "
"; /* if (!label_find_id(__('Shared'), $_SESSION["uid"])) -- 2.39.5