summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-09-10 23:45:21 -0600
committerGitHub <noreply@github.com>2022-09-10 23:45:21 -0600
commit07915e1d7ea94fb554d11487e18478cddb2db02f (patch)
tree88638ef60cc6912e251d624970730c936f548e6a /test
parent6c56c809986cb67e76f865ef324e5ff35ce5b850 (diff)
resolves #4351 force encoding of attribute data passed via CLI to UTF-8 if transcoding fails (PR #4354)
Diffstat (limited to 'test')
-rw-r--r--test/options_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/options_test.rb b/test/options_test.rb
index 29ffd68d..4e649998 100644
--- a/test/options_test.rb
+++ b/test/options_test.rb
@@ -146,6 +146,14 @@ context 'Options' do
assert_nil options[:attributes]
end
+ test 'should gracefully force encoding to UTF-8 if encoding on string is mislabeled' do
+ args = ['-a', ((%w(platform-name 云平台).join '=').force_encoding Encoding::ASCII_8BIT), '-']
+ options = Asciidoctor::Cli::Options.parse! args
+
+ assert_equal '云平台', options[:attributes]['platform-name']
+ assert_equal Encoding::UTF_8, options[:attributes]['platform-name'].encoding
+ end
+
test 'should allow safe mode to be specified' do
options = Asciidoctor::Cli::Options.parse! %w(-S safe test/fixtures/sample.adoc)
assert_equal Asciidoctor::SafeMode::SAFE, options[:safe]