diff options
| author | Denis Ledoux <dle@odoo.com> | 2017-03-09 17:07:15 +0100 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2017-03-10 17:09:11 +0100 |
| commit | 466e2b8c9fd4454aa46782fdbba5722285f30b53 (patch) | |
| tree | e129d8a170168531abc8f65aa069e2fec8d9979d | |
| parent | e6e6a8889f3f302539ee4b4b46c6c6c8487e1a06 (diff) | |
[FIX] mail: URL regex to make links clickable in chatter messages
The former URL took way too many steps to resolve
`www.odoo.com(odoo-odoo-odoo)`, more than 1 minute
according to the case, and it stucked the web client
(the entire browser actually),
and it ended matching the whole sentence as a link,
included `(odoo-odoo-odoo)`
This new regex is much simpler, resolve the above case,
and does not match `odoo-odoo-odoo` as part of the link
opw-715797
| -rw-r--r-- | addons/mail/static/src/js/chat_manager.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index a44921dc494..f22457e2cb0 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -112,8 +112,9 @@ function _parse_and_transform(nodes, transform_function) { }).join(""); } -// suggested regexp (gruber url matching regexp, adapted to js, see https://gist.github.com/gruber/8891611) -var url_regexp = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi; +// Suggested URL Javascript regex of http://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url +// Adapted to make http(s):// not required if (and only if) www. is given. So `should.notmatch` does not match. +var url_regexp = /\b(?:https?:\/\/|(www\.))[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,13}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi; function add_link (node, transform_children) { if (node.nodeType === 3) { // text node return node.data.replace(url_regexp, function (url) { |
