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

Feature test for issue #606 and disable the optimization if the bug is present #618

Closed
Closed
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
18 changes: 12 additions & 6 deletions lib/i18n/backend/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,21 @@ def load_rb(filename)

# Loads a YAML translations file. The data must have locales as
# toplevel keys.
def load_yml(filename)
begin
if YAML.respond_to?(:unsafe_load_file) # Psych 4.0 way
if YAML.respond_to?(:unsafe_load_file) && YAML.unsafe_load_file(File.expand_path("test_issue_606.yml", __dir__), symbolize_names: true).keys.first.encoding == Encoding::UTF_8
def load_yml(filename)
begin
[YAML.unsafe_load_file(filename, symbolize_names: true, freeze: true), true]
else
rescue TypeError, ScriptError, StandardError => e
raise InvalidLocaleData.new(filename, e.inspect)
end
end
else
def load_yml(filename)
begin
[YAML.load_file(filename), false]
rescue TypeError, ScriptError, StandardError => e
raise InvalidLocaleData.new(filename, e.inspect)
end
rescue TypeError, ScriptError, StandardError => e
raise InvalidLocaleData.new(filename, e.inspect)
end
end
alias_method :load_yaml, :load_yml
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/backend/test_issue_606.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
√: ~