Commit cd5b06dd authored by Fatih Acet's avatar Fatih Acet

Merge branch 'gfm-autocomplete-char-in-middle' into 'master'

Fixed GFM autocomplete to disallow non-word characters in string

## What does this MR do?

Disallows GFM autocomplete working when a non-word character is enter in the middle of the string.

## Screenshots (if relevant)

![Screen_Shot_2016-12-12_at_09.47.46](/uploads/aa6463a57b97c103c69eab6bb1d80540/Screen_Shot_2016-12-12_at_09.47.46.png)

## What are the relevant issue numbers?

Closes #25540

See merge request !8035
parents 4c441682 089dbc7d
......@@ -67,14 +67,15 @@
// 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;
var _a, _y, regexp, match, atSymbols;
atSymbols = 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 + "(?!\\W)([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)|([^\\x00-\\xff]*)$", 'gi');
regexp = new RegExp("(?:\\B|\\W|\\s)" + flag + "(?![" + atSymbols + "])([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)$", 'gi');
match = regexp.exec(subtext);
......
......@@ -89,4 +89,12 @@ feature 'GFM autocomplete', feature: true, js: true do
end
end
end
it 'doesnt open autocomplete after non-word character' do
page.within '.timeline-content-form' do
find('#note_note').native.send_keys("@#{user.username[0..2]}!")
end
expect(page).not_to have_selector('.atwho-view')
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment