From 9022877cc60efb694578506771c294c25793415e Mon Sep 17 00:00:00 2001 From: Xavid Date: Fri, 6 May 2016 22:01:56 -0400 Subject: [PATCH 1/2] Remove [ and ] from the regexp used by the URL filter. These characters are rarely used in URLs, and including them leads to mislinkifying when editing various formats, such as wiki markup formats that use [] around links. --- src/static/js/linestylefilter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/js/linestylefilter.js b/src/static/js/linestylefilter.js index 936805151..3cf7a510a 100644 --- a/src/static/js/linestylefilter.js +++ b/src/static/js/linestylefilter.js @@ -265,7 +265,7 @@ linestylefilter.getRegexpFilter = function(regExp, tag) linestylefilter.REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/; -linestylefilter.REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#!;()\[\]$]/.source + '|' + linestylefilter.REGEX_WORDCHAR.source + ')'); +linestylefilter.REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#!;()$]/.source + '|' + linestylefilter.REGEX_WORDCHAR.source + ')'); linestylefilter.REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|nfs):\/\/|(about|geo|mailto|tel):|www\.)/.source + linestylefilter.REGEX_URLCHAR.source + '*(?![:.,;])' + linestylefilter.REGEX_URLCHAR.source, 'g'); linestylefilter.getURLFilter = linestylefilter.getRegexpFilter( linestylefilter.REGEX_URL, 'url'); From 28aa3b28d624d5085d49073ab7c2d6b00ff7450e Mon Sep 17 00:00:00 2001 From: Xavid Date: Mon, 27 Jun 2016 16:20:12 -0400 Subject: [PATCH 2/2] Add a frontend test for URLs followed by a ]. --- tests/frontend/specs/urls_become_clickable.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/frontend/specs/urls_become_clickable.js b/tests/frontend/specs/urls_become_clickable.js index 2de60bf9c..b989717e2 100644 --- a/tests/frontend/specs/urls_become_clickable.js +++ b/tests/frontend/specs/urls_become_clickable.js @@ -44,4 +44,27 @@ describe("urls", function(){ }, 2000).done(done); }); + it("when you enter a url followed by a ], the ] is not included in the URL", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + + //get the first text element out of the inner iframe + var firstTextElement = inner$("div").first(); + var url = "http://etherpad.org/"; + + // simulate key presses to delete content + firstTextElement.sendkeys('{selectall}'); // select all + firstTextElement.sendkeys('{del}'); // clear the first line + firstTextElement.sendkeys(url); // insert a URL + firstTextElement.sendkeys(']'); // put a ] after it + + helper.waitFor(function(){ + if(inner$("div").first().find("a").length === 1){ // if it contains an A link + if(inner$("div").first().find("a")[0].href === url){ + return true; + } + }; + }, 2000).done(done); + }); + });