diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2024-05-12 15:10:16 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-12 13:10:16 -0600 |
| commit | 8ab38887cb9ab0440dd5ca2499a5ccbf80feedc9 (patch) | |
| tree | f0c559bc1f032a5f27ef67da80b314ab46e9cba5 /lib | |
| parent | 45e8c5421ed46a175f20cbd58d567d8292175f35 (diff) | |
resolves #4570 fix crash when parsing xref shorthand when target starts with URL protocol (PR #4585)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor/rx.rb | 4 | ||||
| -rw-r--r-- | lib/asciidoctor/substitutors.rb | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/asciidoctor/rx.rb b/lib/asciidoctor/rx.rb index 5ba6ba1f..1d793664 100644 --- a/lib/asciidoctor/rx.rb +++ b/lib/asciidoctor/rx.rb @@ -522,9 +522,9 @@ module Asciidoctor # if RUBY_ENGINE == 'opal' # NOTE In JavaScript, a back reference succeeds if not set; invert the logic to give it a match to refute - InlineLinkRx = %r((^|link:|#{CG_BLANK}|\\?<(?=\\?(?:https?|file|ftp|irc)(:))|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|(?!\2)([^\s]*?)>|([^\s\[\]<]*([^\s,.?!\[\]<\)])))) + InlineLinkRx = %r((^|link:|#{CG_BLANK}|\\?<(?=\\?(?:https?|file|ftp|irc)(:))|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|(?!\2)([^\s]+?)>|([^\s\[\]<]*([^\s,.?!\[\]<\)])))) else - InlineLinkRx = %r((^|link:|#{CG_BLANK}|\\?<()|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|\2([^\s]*?)>|([^\s\[\]<]*([^\s,.?!\[\]<\)]))))m + InlineLinkRx = %r((^|link:|#{CG_BLANK}|\\?<()|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|\2([^\s]+?)>|([^\s\[\]<]*([^\s,.?!\[\]<\)]))))m end # Match a link or e-mail inline macro. diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb index 3f5bd6af..e8c6325b 100644 --- a/lib/asciidoctor/substitutors.rb +++ b/lib/asciidoctor/substitutors.rb @@ -538,9 +538,8 @@ module Substitutors # honor the escapes next $&.slice 1, $&.length if $1.start_with? RS next %(#{$1}#{$&.slice $1.length + 1, $&.length}) if $3.start_with? RS - target = $3 + $6 - next $& if target == $3 - doc.register :links, target + next $& unless $6 + doc.register :links, (target = $3 + $6) link_text = (doc_attrs.key? 'hide-uri-scheme') ? (target.sub UriSniffRx, '') : target (Inline.new self, :anchor, link_text, type: :link, target: target, attributes: { 'role' => 'bare' }).convert else |
