summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-10-12 01:40:09 -0600
committerGitHub <noreply@github.com>2023-10-12 01:40:09 -0600
commit7e34ca0be2fb6329655d6e3d86824ff1e9af4675 (patch)
treeab7287dcc30ddc59f69a0d54837ddf8d601710d2 /lib
parent1d569e79d1e3d57608f4a338cd9976977232f13e (diff)
resolves #3526 return nil if name passed to Asciidoctor::SafeMode.value_for_name is not recognized (PR #4496)
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor.rb2
-rw-r--r--lib/asciidoctor/document.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb
index 45c28f6a..386b90c4 100644
--- a/lib/asciidoctor.rb
+++ b/lib/asciidoctor.rb
@@ -92,7 +92,7 @@ module Asciidoctor
@names_by_value = (constants false).map {|sym| [(const_get sym), sym.to_s.downcase] }.sort {|(a), (b)| a <=> b }.to_h
def self.value_for_name name
- const_get name.upcase, false
+ const_get name.upcase, false rescue nil
end
def self.name_for_value value
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb
index af5fb51d..71fb887a 100644
--- a/lib/asciidoctor/document.rb
+++ b/lib/asciidoctor/document.rb
@@ -323,7 +323,7 @@ class Document < AbstractBlock
# be permissive in case API user wants to define new levels
@safe = safe_mode
else
- @safe = (SafeMode.value_for_name safe_mode) rescue SafeMode::SECURE
+ @safe = (SafeMode.value_for_name safe_mode) || SafeMode::SECURE
end
input_mtime = options.delete :input_mtime
@compat_mode = attr_overrides.key? 'compat-mode'