summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-02-20 23:47:59 -0700
committerDan Allen <dan.j.allen@gmail.com>2023-02-21 02:48:13 -0700
commit3939f0e7dbdc961d8ed103c422380ceaea72a92c (patch)
treee1180a768e56cbcf07595f7f5e88e0ef2307792d
parent388c23b49f2c6ff9ed1daa4bdc8abfc3a98daf99 (diff)
resolves #4390 fix call order so use of an include file with invalid encoding continues to raise error when using Ruby >= 3.2.0
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/reader.rb3
2 files changed, 3 insertions, 1 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 8b9c602a..16710d50 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -41,6 +41,7 @@ Compliance::
* Don't promote level-0 special section at start of document to document title (#4151)
* Disallow the use of dot (`.`) in the name of a named element attribute (#4147)
* Disallow the use of the left square bracket in an attribute list on formatted text (#4306)
+ * Fix call order so use of an include file with invalid encoding continues to raise error when using Ruby >= 3.2.0
* Drop support for Ruby < 2.5 and JRuby < 9.2
Improvements::
diff --git a/lib/asciidoctor/reader.rb b/lib/asciidoctor/reader.rb
index c101fd9d..fbbad007 100644
--- a/lib/asciidoctor/reader.rb
+++ b/lib/asciidoctor/reader.rb
@@ -1189,15 +1189,16 @@ class PreprocessorReader < Reader
push_include inc_lines, inc_path, relpath, inc_offset, parsed_attrs
end
else
+ inc_content = nil
begin
# NOTE read content before shift so cursor is only advanced if IO operation succeeds
inc_content = reader.call(inc_path, read_mode) {|f| f.read }
shift
- push_include inc_content, inc_path, relpath, 1, parsed_attrs
rescue
logger.error message_with_context %(include #{target_type} not readable: #{inc_path}), source_location: cursor
return replace_next_line %(Unresolved directive in #{@path} - include::#{expanded_target}[#{attrlist}])
end
+ push_include inc_content, inc_path, relpath, 1, parsed_attrs
end
true
end