fix(simpleautolink): fix mail simpleAutoLink to ignore urls with @ symbol

Urls with @ symbol will not be incorrectly converted to mail addressed

Closes #204
This commit is contained in:
Estevão Soares dos Santos 2015-10-07 04:46:28 +01:00
parent c4e82d855e
commit 8ebb25e486
8 changed files with 16 additions and 2 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -5,7 +5,7 @@ showdown.subParser('autoLinks', function (text, options) {
var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi,
delimUrlRegex = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi,
simpleMailRegex = /\b(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)\b/gi,
simpleMailRegex = /(?:^|[ \n\t])([A-Za-z0-9!#$%&'*+-/=?^_`\{|}~\.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?:$|[ \n\t])/gi,
delimMailRegex = /<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
text = text.replace(delimUrlRegex, '<a href=\"$1\">$1</a>');

View File

@ -0,0 +1,7 @@
<p><a href="http://website.com/img@x2.jpg">http://website.com/img@x2.jpg</a></p>
<p><a href="http://website.com/img-x2.jpg">http://website.com/img-x2.jpg</a></p>
<p><a href="http://website.com/img@x2">http://website.com/img@x2</a></p>
<p><a href="http://website.com/img@.jpg">http://website.com/img@.jpg</a></p>

View File

@ -0,0 +1,7 @@
http://website.com/img@x2.jpg
http://website.com/img-x2.jpg
http://website.com/img@x2
http://website.com/img@.jpg

View File

@ -15,7 +15,7 @@ describe('makeHtml() features testsuite', function () {
converter = new showdown.Converter({parseImgDimensions: true});
} else if (testsuite[i].name === '#69.header_level_start') {
converter = new showdown.Converter({headerLevelStart: 3});
} else if (testsuite[i].name === '#164.1.simple_autolink') {
} else if (testsuite[i].name === '#164.1.simple_autolink' || testsuite[i].name === '#204.certain-links-with-at-and-dot-break-url') {
converter = new showdown.Converter({simplifiedAutoLink: true});
} else if (testsuite[i].name === '#164.2.disallow_underscore_emphasis_mid_word') {
converter = new showdown.Converter({literalMidWordUnderscores: true});