From d24f20d32083d44826c6ebc5c0cb59753b28c6da Mon Sep 17 00:00:00 2001 From: Frank Hochmuth Date: Sun, 11 Oct 2026 23:15:13 +0200 Subject: [PATCH] =?UTF-8?q?URL=20with=20the=20=E2=80=9C=5Fblank=E2=80=9D?= =?UTF-8?q?=20target=20attribute=20and=20rel=3D"noopener"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fp-plugins/bbcode/plugin.bbcode.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fp-plugins/bbcode/plugin.bbcode.php b/fp-plugins/bbcode/plugin.bbcode.php index 0df9db9b..f2cbb171 100644 --- a/fp-plugins/bbcode/plugin.bbcode.php +++ b/fp-plugins/bbcode/plugin.bbcode.php @@ -365,8 +365,14 @@ function do_bbcode_url($action, $attributes, $content, $params, $node_object) { $the_url = $local ? (BLOG_BASEURL . $url) : $url; // DMKE: uh? $content = $content; - $rel = isset($attributes ['rel']) ? ' rel="' . $attributes ['rel'] . '"' : ''; - $target = isset($attributes ['target']) ? ' target="'. $attributes ['target'] . '"' : ''; + // Open URL links in a new tab by default; keep explicitly requested targets. + $targetValue = isset($attributes ['target']) ? (string) $attributes ['target'] : '_blank'; + $relValue = isset($attributes ['rel']) ? trim((string) $attributes ['rel']) : ''; + if (strcasecmp($targetValue, '_blank') === 0 && !preg_match('/(?:^|\s)noopener(?:\s|$)/i', $relValue)) { + $relValue = trim($relValue . ' noopener'); + } + $rel = $relValue !== '' ? ' rel="' . plugin_bbcode_escape_html_attribute($relValue) . '"' : ''; + $target = ' target="' . plugin_bbcode_escape_html_attribute($targetValue) . '"'; $extern = !$local ? ' class="externlink" title="' . $lang ['plugin'] ['bbcode'] ['go_to'] . ' ' . $the_url . '"' : ''; return '' . $content . ''; }