Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix frozen string Ruby 3.4 warnings. #5423

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/dynamic_errors_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def error_messages_for(*params)
end
end.join.html_safe

contents = ''
contents = +''
contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
contents << content_tag(:p, message) unless message.blank?
contents << content_tag(:ul, error_messages)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/rubygems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ def rubygem_security_events_link(rubygem)
end

def links_to_owners(rubygem)
rubygem.owners.sort_by(&:id).inject("") { |link, owner| link << link_to_user(owner) }.html_safe
rubygem.owners.sort_by(&:id).inject(+"") { |link, owner| link << link_to_user(owner) }.html_safe
end

def links_to_owners_without_mfa(rubygem)
rubygem.owners.without_mfa.sort_by(&:id).inject("") { |link, owner| link << link_to_user(owner) }.html_safe
rubygem.owners.without_mfa.sort_by(&:id).inject(+"") { |link, owner| link << link_to_user(owner) }.html_safe
end

def link_to_user(user)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/api/v1/api_keys_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def self.should_expect_otp_for_update
context "with credentials with invalid encoding" do
setup do
@user = create(:user)
authorize_with("\x12\xff\x12:creds".force_encoding(Encoding::UTF_8))
authorize_with(String.new("\x12\xff\x12:creds", encoding: Encoding::UTF_8))
get :show
end
should_deny_access
Expand Down
8 changes: 4 additions & 4 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -981,20 +981,20 @@ class UserTest < ActiveSupport::TestCase

should "preserve valid characters so that the format error can be returned" do
# UTF-8 "香" character, which is valid UTF-8, but we reject utf-8 in email addresses
assert_equal "香@example.com", User.normalize_email("\[email protected]".force_encoding("utf-8"))
assert_equal "香@example.com", User.normalize_email(String.new("\[email protected]", encoding: "utf-8"))

# ISO-8859-1 "Å" character (valid in ISO-8859-1)
encoded_email = "myem\[email protected]".force_encoding("ISO-8859-1")
encoded_email = String.new("myem\[email protected]", encoding: "ISO-8859-1")

assert_equal encoded_email, User.normalize_email(encoded_email)
end

should "return an empty string on invalid inputs" do
# bad encoding when sent as ASCII-8BIT
assert_equal "", User.normalize_email("\[email protected]".force_encoding("ascii"))
assert_equal "", User.normalize_email(String.new("\[email protected]", encoding: "ascii"))

# ISO-8859-1 "Å" character (invalid in UTF-8, which uses \xC385 for this character)
assert_equal "", User.normalize_email("myem\[email protected]".force_encoding("UTF-8"))
assert_equal "", User.normalize_email(String.new("myem\[email protected]", encoding: "UTF-8"))
end

should "return an empty string for nil" do
Expand Down
Loading