Commit 96f8ad06 authored by Douwe Maan's avatar Douwe Maan

Properly detect label reference if followed by period or question mark

parent 99fdbe4c
...@@ -85,10 +85,15 @@ class Label < ActiveRecord::Base ...@@ -85,10 +85,15 @@ class Label < ActiveRecord::Base
(#{Project.reference_pattern})? (#{Project.reference_pattern})?
#{Regexp.escape(reference_prefix)} #{Regexp.escape(reference_prefix)}
(?: (?:
(?<label_id>\d+(?!\S\w)\b) | # Integer-based label ID, or (?<label_id>\d+(?!\S\w)\b)
| # Integer-based label ID, or
(?<label_name> (?<label_name>
[A-Za-z0-9_\-\?\.&]+ | # String-based single-word label title, or # String-based single-word label title, or
".+?" # String-based multi-word label surrounded in quotes [A-Za-z0-9_\-\?\.&]+
(?<!\.|\?)
|
# String-based multi-word label surrounded in quotes
".+?"
) )
) )
}x }x
......
---
title: Properly detect label reference if followed by period or question mark
merge_request:
author:
type: fixed
...@@ -149,8 +149,8 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -149,8 +149,8 @@ describe Banzai::Filter::LabelReferenceFilter do
end end
it 'links with adjacent text' do it 'links with adjacent text' do
doc = reference_filter("Label (#{reference}).") doc = reference_filter("Label #{reference}.")
expect(doc.to_html).to match(%r(\(<a.+><span.+>\?g\.fm&amp;</span></a>\)\.)) expect(doc.to_html).to match(%r(<a.+><span.+>\?g\.fm&amp;</span></a>\.))
end end
it 'ignores invalid label names' do it 'ignores invalid label names' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment