Commit e31a9dd253d545e3d364a007994a0de6c1c1896c
1 parent
d1d19aec
Exists in
master
and in
4 other branches
GFM refactor: Update pattern to avoid an extra HTML entities check
Showing
1 changed file
with
4 additions
and
7 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
| 1 | 1 | module GitlabMarkdownHelper |
| 2 | 2 | REFERENCE_PATTERN = %r{ |
| 3 | - (\W)? # Prefix (1) | |
| 3 | + ([^\w&;])? # Prefix (1) | |
| 4 | 4 | ( # Reference (2) |
| 5 | 5 | @([\w\._]+) | # User name (3) |
| 6 | 6 | [#!$](\d+) | # Issue/MR/Snippet ID (4) |
| 7 | 7 | [\h]{6,40} # Commit ID (2) |
| 8 | 8 | ) |
| 9 | - (\W)? # Suffix (5) | |
| 9 | + ([^\w&;])? # Suffix (5) | |
| 10 | 10 | }x.freeze |
| 11 | 11 | |
| 12 | 12 | def gfm(text, html_options = {}) |
| ... | ... | @@ -86,11 +86,8 @@ module GitlabMarkdownHelper |
| 86 | 86 | |
| 87 | 87 | # issue: #123 |
| 88 | 88 | when /^#/ |
| 89 | - # avoid HTML entities | |
| 90 | - unless vals[:prefix].try(:end_with?, "&") && vals[:suffix].try(:start_with?, ";") | |
| 91 | - issue = @project.issues.where(id: vals[:reference_id]).first | |
| 92 | - 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 | |
| 93 | - end | |
| 89 | + issue = @project.issues.where(id: vals[:reference_id]).first | |
| 90 | + 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 | |
| 94 | 91 | |
| 95 | 92 | # merge request: !123 |
| 96 | 93 | when /^!/ | ... | ... |