Skip to content

Commit d99bbe1

Browse files
authored
Merge pull request #1289 from fwolfst/1288-let_link_to_blank_find_link_to_if_and_unless
[Fix #1288] Let LinkToBlank find violations in link_to_if and link_to_unless
2 parents bb1d373 + e8d60f3 commit d99bbe1

File tree

3 files changed

+396
-93
lines changed

3 files changed

+396
-93
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1288](https://github.com/rubocop/rubocop-rails/issues/1288): Let `Rails/LinkToBlank` look into `link_to_if` and `link_to_unless`, too. ([@fwolfst][])

lib/rubocop/cop/rails/link_to_blank.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module RuboCop
44
module Cop
55
module Rails
6-
# Checks for calls to `link_to` that contain a
6+
# Checks for calls to `link_to`, `link_to_if`, and `link_to_unless` methods that contain a
77
# `target: '_blank'` but no `rel: 'noopener'`. This can be a security
88
# risk as the loaded page will have control over the previous page
99
# and could change its location for phishing purposes.
@@ -24,7 +24,7 @@ class LinkToBlank < Base
2424
extend AutoCorrector
2525

2626
MSG = 'Specify a `:rel` option containing noopener.'
27-
RESTRICT_ON_SEND = %i[link_to].freeze
27+
RESTRICT_ON_SEND = %i[link_to link_to_if link_to_unless].freeze
2828

2929
def_node_matcher :blank_target?, <<~PATTERN
3030
(pair {(sym :target) (str "target")} {(str "_blank") (sym :_blank)})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy