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

Preventing transliterator constant from being modified for concurrency concerns #184

Merged
merged 1 commit into from Dec 25, 2012
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/i18n/backend/transliterator.rb
Expand Up @@ -67,11 +67,11 @@ class HashTransliterator
"ů"=>"u", "Ű"=>"U", "ű"=>"u", "Ų"=>"U", "ų"=>"u", "Ŵ"=>"W", "ŵ"=>"w",
"Ŷ"=>"Y", "ŷ"=>"y", "Ÿ"=>"Y", "Ź"=>"Z", "ź"=>"z", "Ż"=>"Z", "ż"=>"z",
"Ž"=>"Z", "ž"=>"z"
}
}.freeze

def initialize(rule = nil)
@rule = rule
add DEFAULT_APPROXIMATIONS
add DEFAULT_APPROXIMATIONS.dup
add rule if rule
end

Expand Down
4 changes: 4 additions & 0 deletions test/backend/transliterator_test.rb
Expand Up @@ -79,4 +79,8 @@ def setup
assert_not_equal "ue", transliterator.transliterate(char)
end

test "DEFAULT_APPROXIMATIONS is frozen to prevent concurrency issues" do
assert I18n::Backend::Transliterator::HashTransliterator::DEFAULT_APPROXIMATIONS.frozen?
end

end