Skip to content

Commit

Permalink
Avoid creating match object when checking for illegal header value
Browse files Browse the repository at this point in the history
We can use `match?` to check against the illegal header value regexp,
since we don't need the match data result.
  • Loading branch information
carlosantoniodasilva committed Jun 27, 2023
1 parent be7cde2 commit 0b89567
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/metal/redirecting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def _ensure_url_is_http_header_safe(url)
# Attempt to comply with the set of valid token characters
# defined for an HTTP header value in
# https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6
if url.match(ILLEGAL_HEADER_VALUE_REGEX)
if url.match?(ILLEGAL_HEADER_VALUE_REGEX)
msg = "The redirect URL #{url} contains one or more illegal HTTP header field character. " \
"Set of legal characters defined in https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6"
raise UnsafeRedirectError, msg
Expand Down

0 comments on commit 0b89567

Please sign in to comment.