Skip to content

Commit c49a03b

Browse files
committed
Rebuild 1.6.1
1 parent 18ba38b commit c49a03b

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

dist/Autolinker.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,11 @@ Autolinker.htmlParser.HtmlParser = Autolinker.Util.extend( Object, {
18331833
tagNameRegex = /[0-9a-zA-Z][0-9a-zA-Z:]*/,
18341834
attrNameRegex = /[^\s"'>\/=\x00-\x1F\x7F]+/, // the unicode range accounts for excluding control chars, and the delete char
18351835
attrValueRegex = /(?:"[^"]*?"|'[^']*?'|[^'"=<>`\s]+)/, // double quoted, single quoted, or unquoted attribute values
1836-
nameEqualsValueRegex = attrNameRegex.source + '(?:\\s*=\\s*' + attrValueRegex.source + ')?'; // optional '=[value]'
1836+
optionalAttrValueRegex = '(?:\\s*?=\\s*?' + attrValueRegex.source + ')?'; // optional '=[value]'
1837+
1838+
var getNameEqualsValueRegex = function(group) {
1839+
return '(?=(' + attrNameRegex.source + '))\\' + group + optionalAttrValueRegex;
1840+
};
18371841

18381842
return new RegExp( [
18391843
// for <!DOCTYPE> tag. Ex: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">)
@@ -1847,7 +1851,8 @@ Autolinker.htmlParser.HtmlParser = Autolinker.Util.extend( Object, {
18471851
// Either:
18481852
// A. attr="value", or
18491853
// B. "value" alone (To cover example doctype tag: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">)
1850-
'(?:', nameEqualsValueRegex, '|', attrValueRegex.source + ')',
1854+
// *** Capturing Group 2 - Pseudo-atomic group for attrNameRegex
1855+
'(?:', getNameEqualsValueRegex(2), '|', attrValueRegex.source + ')',
18511856
')*',
18521857
'>',
18531858
')',
@@ -1857,10 +1862,10 @@ Autolinker.htmlParser.HtmlParser = Autolinker.Util.extend( Object, {
18571862
// All other HTML tags (i.e. tags that are not <!DOCTYPE>)
18581863
'(?:',
18591864
'<(/)?', // Beginning of a tag or comment. Either '<' for a start tag, or '</' for an end tag.
1860-
// *** Capturing Group 2: The slash or an empty string. Slash ('/') for end tag, empty string for start or self-closing tag.
1865+
// *** Capturing Group 3: The slash or an empty string. Slash ('/') for end tag, empty string for start or self-closing tag.
18611866

18621867
'(?:',
1863-
commentTagRegex.source, // *** Capturing Group 3 - A Comment Tag's Text
1868+
commentTagRegex.source, // *** Capturing Group 4 - A Comment Tag's Text
18641869

18651870
'|',
18661871

@@ -1869,7 +1874,7 @@ Autolinker.htmlParser.HtmlParser = Autolinker.Util.extend( Object, {
18691874
// to fix a regex time complexity issue seen with the
18701875
// example in https://github.com/gregjacobs/Autolinker.js/issues/172
18711876
'(?:',
1872-
// *** Capturing Group 4 - The tag name for a tag without attributes
1877+
// *** Capturing Group 5 - The tag name for a tag without attributes
18731878
'(' + tagNameRegex.source + ')',
18741879

18751880
'\\s*/?', // any trailing spaces and optional '/' before the closing '>'
@@ -1882,15 +1887,16 @@ Autolinker.htmlParser.HtmlParser = Autolinker.Util.extend( Object, {
18821887
// to fix a regex time complexity issue seen with the
18831888
// example in https://github.com/gregjacobs/Autolinker.js/issues/172
18841889
'(?:',
1885-
// *** Capturing Group 5 - The tag name for a tag with attributes
1890+
// *** Capturing Group 6 - The tag name for a tag with attributes
18861891
'(' + tagNameRegex.source + ')',
18871892

18881893
'\\s+', // must have at least one space after the tag name to prevent ReDoS issue (issue #172)
18891894

18901895
// Zero or more attributes following the tag name
18911896
'(?:',
18921897
'(?:\\s+|\\b)', // any number of whitespace chars before an attribute. NOTE: Using \s* here throws Chrome into an infinite loop for some reason, so using \s+|\b instead
1893-
nameEqualsValueRegex, // attr="value" (with optional ="value" part)
1898+
// *** Capturing Group 7 - Pseudo-atomic group for attrNameRegex
1899+
getNameEqualsValueRegex(7), // attr="value" (with optional ="value" part)
18941900
')*',
18951901

18961902
'\\s*/?', // any trailing spaces and optional '/' before the closing '>'
@@ -1928,9 +1934,9 @@ Autolinker.htmlParser.HtmlParser = Autolinker.Util.extend( Object, {
19281934

19291935
while( ( currentResult = htmlRegex.exec( html ) ) !== null ) {
19301936
var tagText = currentResult[ 0 ],
1931-
commentText = currentResult[ 3 ], // if we've matched a comment
1932-
tagName = currentResult[ 1 ] || currentResult[ 4 ] || currentResult[ 5 ], // The <!DOCTYPE> tag (ex: "!DOCTYPE"), or another tag (ex: "a" or "img")
1933-
isClosingTag = !!currentResult[ 2 ],
1937+
commentText = currentResult[ 4 ], // if we've matched a comment
1938+
tagName = currentResult[ 1 ] || currentResult[ 5 ] || currentResult[ 6 ], // The <!DOCTYPE> tag (ex: "!DOCTYPE"), or another tag (ex: "a" or "img")
1939+
isClosingTag = !!currentResult[ 3 ],
19341940
offset = currentResult.index,
19351941
inBetweenTagsText = html.substring( lastIndex, offset );
19361942

0 commit comments

Comments
 (0)