diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-25 16:06:34 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-25 16:06:34 -0400 |
commit | b263a33c80a04be4b126c203f0c0d1439f1d5739 (patch) | |
tree | 7c2f4431da62ef090a20af6fe7f0a8d8d22d786f | |
parent | 2651c8a9aaa27e3b66a820469cd5dafd4aec39d3 (diff) | |
download | gitlab-ce-rs-issue-1690.tar.gz |
Better handle label references that aren't actually referencesrs-issue-1690
Fixes #1690
-rw-r--r-- | lib/gitlab/markdown/label_reference_filter.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/markdown/label_reference_filter_spec.rb | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/gitlab/markdown/label_reference_filter.rb b/lib/gitlab/markdown/label_reference_filter.rb index a357f28458d..1a77becee89 100644 --- a/lib/gitlab/markdown/label_reference_filter.rb +++ b/lib/gitlab/markdown/label_reference_filter.rb @@ -84,11 +84,11 @@ module Gitlab # # Returns a Hash. def label_params(id, name) - if id > 0 - { id: id } - else + if name # TODO (rspeicher): Don't strip single quotes if we decide to only use double quotes for surrounding. { name: name.tr('\'"', '') } + else + { id: id } end end end diff --git a/spec/lib/gitlab/markdown/label_reference_filter_spec.rb b/spec/lib/gitlab/markdown/label_reference_filter_spec.rb index 9f898837466..c4548e7431f 100644 --- a/spec/lib/gitlab/markdown/label_reference_filter_spec.rb +++ b/spec/lib/gitlab/markdown/label_reference_filter_spec.rb @@ -149,5 +149,12 @@ module Gitlab::Markdown end end end + + describe 'edge cases' do + it 'gracefully handles non-references matching the pattern' do + exp = act = '(format nil "~0f" 3.0) ; 3.0' + expect(filter(act).to_html).to eq exp + end + end end end |