diff options
author | Robert Speicher <rspeicher@gmail.com> | 2012-08-14 11:49:55 +0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2012-08-14 12:33:46 +0400 |
commit | e31a9dd253d545e3d364a007994a0de6c1c1896c (patch) | |
tree | 5159ad772e853fe4f4002a19a027274fc022bcc2 /app | |
parent | d1d19aecdeb73069357885b91dcc0b9f31cde4ba (diff) |
GFM refactor: Update pattern to avoid an extra HTML entities check
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 56e581ea414..7ce3afa6583 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -1,12 +1,12 @@ module GitlabMarkdownHelper REFERENCE_PATTERN = %r{ - (\W)? # Prefix (1) + ([^\w&;])? # Prefix (1) ( # Reference (2) @([\w\._]+) | # User name (3) [#!$](\d+) | # Issue/MR/Snippet ID (4) [\h]{6,40} # Commit ID (2) ) - (\W)? # Suffix (5) + ([^\w&;])? # Suffix (5) }x.freeze def gfm(text, html_options = {}) @@ -86,11 +86,8 @@ module GitlabMarkdownHelper # issue: #123 when /^#/ - # avoid HTML entities - unless vals[:prefix].try(:end_with?, "&") && vals[:suffix].try(:start_with?, ";") - issue = @project.issues.where(id: vals[:reference_id]).first - link_to("##{issue.id}", project_issue_path(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) if issue - end + issue = @project.issues.where(id: vals[:reference_id]).first + link_to("##{issue.id}", project_issue_path(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) if issue # merge request: !123 when /^!/ |