Skip to content

Commit

Permalink
fix(simpleautolink): fix mail simpleAutoLink to ignore urls with @ sy…
Browse files Browse the repository at this point in the history
…mbol

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

Closes #204
  • Loading branch information
tivie committed Oct 7, 2015
1 parent c4e82d8 commit 8ebb25e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/subParsers/autoLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p><a href="http://website.com/[email protected]">http://website.com/[email protected]</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/[email protected]">http://website.com/[email protected]</a></p>
7 changes: 7 additions & 0 deletions test/features/#204.certain-links-with-at-and-dot-break-url.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
http://website.com/[email protected]

http://website.com/img-x2.jpg

http://website.com/img@x2

http://website.com/[email protected]
2 changes: 1 addition & 1 deletion test/node/testsuite.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down

0 comments on commit 8ebb25e

Please sign in to comment.