Skip to content

Commit

Permalink
Improve parsing of HTML entities for URLs.
Browse files Browse the repository at this point in the history
Previously, link like `"http://example.com/"` was changed into
`"http://example.com/";` because of wrong parsing of entities.
  • Loading branch information
KamilaBorowska committed Apr 28, 2015
1 parent 923a246 commit c530986
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions js/battledata.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ var baseSpeciesChart = {

// Precompile often used regular expression for links.
var domainRegex = '[a-z0-9\\-]+(?:[.][a-z0-9\\-]+)*';
var parenthesisRegex = '[(][^\\s()<>]*[)]';
var parenthesisRegex = '[(](?:[^\\s()<>&]|&amp;)*[)]';
var linkRegex = new RegExp(
'\\b' +
'(?:' +
Expand All @@ -297,13 +297,13 @@ var linkRegex = new RegExp(
'/' +
'(?:' +
'(?:' +
'[^\\s()<>]' +
'[^\\s()&]|&amp;|&quot;' +
'|' + parenthesisRegex +
')*' +
// URLs usually don't end with punctuation, so don't allow
// punctuation symbols that probably aren't related to URL.
'(?:' +
'[^\\s`()<>\\[\\]{}\'".,!?;:]' +
'[^\\s`()\\[\\]{}\'".,!?;:&]' +
'|' + parenthesisRegex +
')' +
')?' +
Expand Down

0 comments on commit c530986

Please sign in to comment.