From 058dd193603910efb12cba84339474e3e8778c31 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Fri, 23 Mar 2018 15:51:28 +0000 Subject: Add ?, !, and : to trailing puncutation excluded from auto-linking --- ...44587-autolinking-includes-trailing-exclamation-marks.yml | 5 +++++ lib/banzai/filter/autolink_filter.rb | 11 ++++++----- spec/lib/banzai/filter/autolink_filter_spec.rb | 12 ++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 changelogs/unreleased/44587-autolinking-includes-trailing-exclamation-marks.yml diff --git a/changelogs/unreleased/44587-autolinking-includes-trailing-exclamation-marks.yml b/changelogs/unreleased/44587-autolinking-includes-trailing-exclamation-marks.yml new file mode 100644 index 00000000000..636fde601ee --- /dev/null +++ b/changelogs/unreleased/44587-autolinking-includes-trailing-exclamation-marks.yml @@ -0,0 +1,5 @@ +--- +title: Don't capture trailing punctuation when autolinking +merge_request: 17965 +author: +type: fixed diff --git a/lib/banzai/filter/autolink_filter.rb b/lib/banzai/filter/autolink_filter.rb index 75b64ae9af2..ce401c1c31c 100644 --- a/lib/banzai/filter/autolink_filter.rb +++ b/lib/banzai/filter/autolink_filter.rb @@ -21,12 +21,13 @@ module Banzai # # See http://en.wikipedia.org/wiki/URI_scheme # - # The negative lookbehind ensures that users can paste a URL followed by a - # period or comma for punctuation without those characters being included - # in the generated link. + # The negative lookbehind ensures that users can paste a URL followed by + # punctuation without those characters being included in the generated + # link. It matches the behaviour of Rinku 2.0.1: + # https://github.com/vmg/rinku/blob/v2.0.1/ext/rinku/autolink.c#L65 # - # Rubular: http://rubular.com/r/JzPhi6DCZp - LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://[^\s>]+)(?]+)(?