From 7241246a04773805397c0eefd44a6fba20f04a1a Mon Sep 17 00:00:00 2001
From: Phil Hughes <me@iamphill.com>
Date: Thu, 22 Dec 2016 16:00:49 +0000
Subject: [PATCH 1/2] Stops GFM special characters interfering with markdown
 tags

---
 app/assets/javascripts/gfm_auto_complete.js.es6 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/assets/javascripts/gfm_auto_complete.js.es6 b/app/assets/javascripts/gfm_auto_complete.js.es6
index cbd8ac4eddd4..12875eaa1c31 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);
 
-- 
GitLab


From 940d8a06422b94ee7a5ff36d91a820fff3d9947b Mon Sep 17 00:00:00 2001
From: Phil Hughes <me@iamphill.com>
Date: Thu, 22 Dec 2016 18:39:00 +0000
Subject: [PATCH 2/2] Added tests for special characters

---
 spec/features/issues/gfm_autocomplete_spec.rb | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb
index df3a467cbb79..d0294908d2c2 100644
--- a/spec/features/issues/gfm_autocomplete_spec.rb
+++ b/spec/features/issues/gfm_autocomplete_spec.rb
@@ -47,6 +47,24 @@
       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
-- 
GitLab