summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2016-12-22 21:25:11 +0000
committerJacob Schatz <jschatz@gitlab.com>2016-12-22 21:25:11 +0000
commit05347e0748118d95724e2bd842f690cba5b03f8e (patch)
treec02a64973945455d5f665dbfa81f64718a14b8a1
parent7ca181d8e03f58a7be1e901645b26bb0cc8e89fb (diff)
parent940d8a06422b94ee7a5ff36d91a820fff3d9947b (diff)
downloadgitlab-ce-05347e0748118d95724e2bd842f690cba5b03f8e.tar.gz
Merge branch 'markdown-input-symbol-regex' into 'master'
Stops GFM special characters interfering with markdown tags See merge request !8265
-rw-r--r--app/assets/javascripts/gfm_auto_complete.js.es67
-rw-r--r--spec/features/issues/gfm_autocomplete_spec.rb18
2 files changed, 22 insertions, 3 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js.es6 b/app/assets/javascripts/gfm_auto_complete.js.es6
index cbd8ac4eddd..12875eaa1c3 100644
--- a/app/assets/javascripts/gfm_auto_complete.js.es6
+++ b/app/assets/javascripts/gfm_auto_complete.js.es6
@@ -74,15 +74,16 @@
// The below is taken from At.js source
// Tweaked to commands to start without a space only if char before is a non-word character
// https://github.com/ichord/At.js
- var _a, _y, regexp, match, atSymbols;
- atSymbols = Object.keys(this.app.controllers).join('|');
+ var _a, _y, regexp, match, atSymbolsWithBar, atSymbolsWithoutBar;
+ atSymbolsWithBar = Object.keys(this.app.controllers).join('|');
+ atSymbolsWithoutBar = Object.keys(this.app.controllers).join('');
subtext = subtext.split(' ').pop();
flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
_a = decodeURI("%C3%80");
_y = decodeURI("%C3%BF");
- regexp = new RegExp("(?:\\B|\\W|\\s)" + flag + "(?![" + atSymbols + "])([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)$", 'gi');
+ regexp = new RegExp("^(?:\\B|[^a-zA-Z0-9_" + atSymbolsWithoutBar + "]|\\s)" + flag + "(?![" + atSymbolsWithBar + "])([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)$", 'gi');
match = regexp.exec(subtext);
diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb
index df3a467cbb7..d0294908d2c 100644
--- a/spec/features/issues/gfm_autocomplete_spec.rb
+++ b/spec/features/issues/gfm_autocomplete_spec.rb
@@ -47,6 +47,24 @@ feature 'GFM autocomplete', feature: true, js: true do
expect_to_wrap(true, label_item, note, label.title)
end
+ it "does not show drpdown when preceded with a special character" do
+ note = find('#note_note')
+ page.within '.timeline-content-form' do
+ note.native.send_keys('')
+ note.native.send_keys("@")
+ note.click
+ end
+
+ expect(page).to have_selector('.atwho-container')
+
+ page.within '.timeline-content-form' do
+ note.native.send_keys("@")
+ note.click
+ end
+
+ expect(page).to have_selector('.atwho-container', visible: false)
+ end
+
it 'doesn\'t wrap for assignee values' do
note = find('#note_note')
page.within '.timeline-content-form' do