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

Parsing an inline link causes processor to crash for certain matches #4570

Open
rymsha opened this issue Mar 26, 2024 · 3 comments
Open

Parsing an inline link causes processor to crash for certain matches #4570

rymsha opened this issue Mar 26, 2024 · 3 comments
Assignees
Milestone

Comments

@rymsha
Copy link

rymsha commented Mar 26, 2024

Recently we started to to see such error.

Downgrading to asciidoctor/docker-asciidoctor:1.66 helps, so the bug must be since Asciidoctor version 2.0.21

/usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:540:in `+': no implicit conversion of nil into String (TypeError)

          target = $3 + $6
                        ^^
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:540:in `block in sub_macros'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:535:in `gsub'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:535:in `sub_macros'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:102:in `block in apply_subs'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:91:in `each'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:91:in `apply_subs'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/table.rb:358:in `text'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/table.rb:378:in `content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:906:in `block (3 levels) in convert_table'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:896:in `each'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:896:in `block (2 levels) in convert_table'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:894:in `each'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:894:in `block in convert_table'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:891:in `each'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:891:in `convert_table'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:81:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:76:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `block in content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `map'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:426:in `convert_section'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:55:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:76:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `block in content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `map'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:425:in `convert_section'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:55:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:76:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `block in content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `map'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/document.rb:1012:in `content'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:227:in `convert_document'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/converter/html5.rb:85:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/document.rb:956:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/convert.rb:118:in `convert'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/convert.rb:190:in `block in convert_file'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/convert.rb:190:in `open'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/convert.rb:190:in `convert_file'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/cli/invoker.rb:129:in `block in invoke!'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/cli/invoker.rb:112:in `each'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/lib/asciidoctor/cli/invoker.rb:112:in `invoke!'
	from /usr/lib/ruby/gems/3.2.0/gems/asciidoctor-2.0.22/bin/asciidoctor:15:in `<top (required)>'
	from /usr/bin/asciidoctor:25:in `load'
	from /usr/bin/asciidoctor:25:in `<main>'
@mojavelinux
Copy link
Member

mojavelinux commented Mar 26, 2024

There's a known issue when invalid syntax is used, such as:

<<https://example.com,Example>>

Can you confirm whether this is the use case that is triggering this error for you, or is there another syntax that is also causing it?

This issue is related to the fix for the following issue #4468. There is always a risk when modifying the parsing regular expressions that it will introduce unexpected match errors that aren't covered by the test suite.

@mojavelinux mojavelinux changed the title no implicit conversion of nil into String (TypeError) Parsing an inline link causes processor to crash for certain matches Mar 26, 2024
@mojavelinux mojavelinux self-assigned this Mar 26, 2024
@mojavelinux mojavelinux added this to the v2.0.x milestone Mar 26, 2024
@rymsha
Copy link
Author

rymsha commented Mar 26, 2024

Yes it was the case
Changed
<<link:https://www.unix.com/man-page/linux/5/crontab,format>>
to
link:https://www.unix.com/man-page/linux/5/crontab[format]

@mojavelinux
Copy link
Member

Thanks. That's good to know.

You should know that the link: prefix is redundant when the target is a URL. That's because https: is recognized as a macro prefix already. See https://docs.asciidoctor.org/asciidoc/latest/macros/link-macro/#when-to-use-the-link-macro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants