summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-12 21:33:25 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-13 11:42:31 -0300
commitf682c0975b3a589d9fc6dae585cf6e36fa9ac348 (patch)
treef0fa9bcc907e0a8ceac0eeca8e244c9568e9aab9 /app
parentc88075f46772d3c462969372fafbd7f3886872b8 (diff)
downloadgitlab-ce-f682c0975b3a589d9fc6dae585cf6e36fa9ac348.tar.gz
Fix markdown rendering for label references that begin with a digit
Diffstat (limited to 'app')
-rw-r--r--app/models/label.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 60c0fff44ce..9b8239d8757 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -52,11 +52,14 @@ class Label < ActiveRecord::Base
# This pattern supports cross-project references.
#
def self.reference_pattern
+ # NOTE: The id pattern only matches when all characters on the expression
+ # are digits, so it will match ~2 but not ~2fa because that's probably a
+ # label name and we want it to be matched as such.
@reference_pattern ||= %r{
(#{Project.reference_pattern})?
#{Regexp.escape(reference_prefix)}
(?:
- (?<label_id>\d+) | # Integer-based label ID, or
+ (?<label_id>\d+(?!\S\w)\b) | # Integer-based label ID, or
(?<label_name>
[A-Za-z0-9_\-\?&]+ | # String-based single-word label title, or
"([^"]*)" # String-based multi-word label surrounded in quotes