Skip to content

Commit

Permalink
feat: html_escape設定を必須に
Browse files Browse the repository at this point in the history
  • Loading branch information
aki77 committed Apr 22, 2024
1 parent 6c5de13 commit 9e0dd90
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.eslint": "explicit"
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.preferences.importModuleSpecifier": "non-relative",
Expand Down
9 changes: 8 additions & 1 deletion lib/copy_tuner_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,20 @@ def initialize
self.upload_disabled_environments = %w[production staging]
self.s3_host = 'copy-tuner-data-prod.s3.amazonaws.com'
self.disable_copyray_comment_injection = false
self.html_escape = false
# TODO: 0.18.0以降のバージョンで初期値をtrueにしたい
self.html_escape = nil
self.ignored_keys = []
self.ignored_key_handler = -> (e) { raise e }

@applied = false
end

def html_escape
raise 'CopyTunerClient.configuration.html_escape is required' if @html_escape.nil?

@html_escape
end

# Allows config options to be read like a hash
#
# @param [Symbol] option Key for a given attribute
Expand Down
2 changes: 1 addition & 1 deletion lib/copy_tuner_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module CopyTunerClient
# Client version
VERSION = '0.16.3'.freeze
VERSION = '0.17.0'.freeze

# API version being used to communicate with the server
API_VERSION = '2.0'.freeze
Expand Down
4 changes: 2 additions & 2 deletions spec/copy_tuner_client/i18n_backend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ def build_backend
expect(cache['en.test.key']).to eq 'default %{interpolate}'
end

it "marks strings as html safe" do
it "dose not mark strings as html safe" do
cache['en.test.key'] = FakeHtmlSafeString.new("Hello")
backend = build_backend
expect(backend.translate('en', 'test.key')).to be_html_safe
expect(backend.translate('en', 'test.key')).to_not be_html_safe
end

it "looks up an array of defaults" do
Expand Down
1 change: 1 addition & 0 deletions spec/support/client_spec_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def reset_config
CopyTunerClient.configure(false) do |config|
config.api_key = 'abc123'
config.s3_host = 'copy-tuner.com'
config.html_escape = true
end
end
end

0 comments on commit 9e0dd90

Please sign in to comment.