Socket
Socket
Sign inDemoInstall

linkifyjs

Package Overview
Dependencies
0
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.4 to 3.0.5

12

dist/linkify-html.js

@@ -32,8 +32,4 @@ var linkifyHtml = (function (linkify) {

// whitespace is parsed properly. Other types of whitespace should already
// be accounted for. > < and " are also frequently relevant ones
amp: "&",
gt: ">",
lt: "<",
nbsp: " ",
quot: "\""
// be accounted for
nbsp: " "
};

@@ -59,3 +55,3 @@ var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/;

if (matches) {
return String.fromCharCode(parseInt(matches[1], 16));
return "&#x" + matches[1] + ";";
}

@@ -66,3 +62,3 @@

if (matches) {
return String.fromCharCode(parseInt(matches[1], 10));
return "&#" + matches[1] + ";";
}

@@ -69,0 +65,0 @@

@@ -1,1 +0,1 @@

var linkifyHtml=function(t){"use strict";function e(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var i=e(t),n={amp:"&",gt:">",lt:"<",nbsp:" ",quot:'"'},s=/^#[xX]([A-Fa-f0-9]+)$/,o=/^#([0-9]+)$/,a=/^([A-Za-z0-9]+)$/,r=function(){function t(t){this.named=t}return t.prototype.parse=function(t){if(t){var e=t.match(s);return e?String.fromCharCode(parseInt(e[1],16)):(e=t.match(o))?String.fromCharCode(parseInt(e[1],10)):(e=t.match(a))?this.named[e[1]]||"&"+e[1]+";":void 0}},t}(),h=/[\t\n\f ]/,u=/[A-Za-z]/,c=/\r\n?/g;function p(t){return h.test(t)}function d(t){return u.test(t)}var f=function(){function t(t,e,i){void 0===i&&(i="precompile"),this.delegate=t,this.entityParser=e,this.mode=i,this.state="beforeData",this.line=-1,this.column=-1,this.input="",this.index=-1,this.tagNameBuffer="",this.states={beforeData:function(){var t=this.peek();if("<"!==t||this.isIgnoredEndTag()){if("precompile"===this.mode&&"\n"===t){var e=this.tagNameBuffer.toLowerCase();"pre"!==e&&"textarea"!==e||this.consume()}this.transitionTo("data"),this.delegate.beginData()}else this.transitionTo("tagOpen"),this.markTagStart(),this.consume()},data:function(){var t=this.peek(),e=this.tagNameBuffer;"<"!==t||this.isIgnoredEndTag()?"&"===t&&"script"!==e&&"style"!==e?(this.consume(),this.delegate.appendToData(this.consumeCharRef()||"&")):(this.consume(),this.delegate.appendToData(t)):(this.delegate.finishData(),this.transitionTo("tagOpen"),this.markTagStart(),this.consume())},tagOpen:function(){var t=this.consume();"!"===t?this.transitionTo("markupDeclarationOpen"):"/"===t?this.transitionTo("endTagOpen"):("@"===t||":"===t||d(t))&&(this.transitionTo("tagName"),this.tagNameBuffer="",this.delegate.beginStartTag(),this.appendToTagName(t))},markupDeclarationOpen:function(){var t=this.consume();"-"===t&&"-"===this.peek()?(this.consume(),this.transitionTo("commentStart"),this.delegate.beginComment()):"DOCTYPE"===t.toUpperCase()+this.input.substring(this.index,this.index+6).toUpperCase()&&(this.consume(),this.consume(),this.consume(),this.consume(),this.consume(),this.consume(),this.transitionTo("doctype"),this.delegate.beginDoctype&&this.delegate.beginDoctype())},doctype:function(){p(this.consume())&&this.transitionTo("beforeDoctypeName")},beforeDoctypeName:function(){var t=this.consume();p(t)||(this.transitionTo("doctypeName"),this.delegate.appendToDoctypeName&&this.delegate.appendToDoctypeName(t.toLowerCase()))},doctypeName:function(){var t=this.consume();p(t)?this.transitionTo("afterDoctypeName"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypeName&&this.delegate.appendToDoctypeName(t.toLowerCase())},afterDoctypeName:function(){var t=this.consume();if(!p(t))if(">"===t)this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData");else{var e=t.toUpperCase()+this.input.substring(this.index,this.index+5).toUpperCase(),i="PUBLIC"===e.toUpperCase(),n="SYSTEM"===e.toUpperCase();(i||n)&&(this.consume(),this.consume(),this.consume(),this.consume(),this.consume(),this.consume()),i?this.transitionTo("afterDoctypePublicKeyword"):n&&this.transitionTo("afterDoctypeSystemKeyword")}},afterDoctypePublicKeyword:function(){var t=this.peek();p(t)?(this.transitionTo("beforeDoctypePublicIdentifier"),this.consume()):'"'===t?(this.transitionTo("doctypePublicIdentifierDoubleQuoted"),this.consume()):"'"===t?(this.transitionTo("doctypePublicIdentifierSingleQuoted"),this.consume()):">"===t&&(this.consume(),this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData"))},doctypePublicIdentifierDoubleQuoted:function(){var t=this.consume();'"'===t?this.transitionTo("afterDoctypePublicIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypePublicIdentifier&&this.delegate.appendToDoctypePublicIdentifier(t)},doctypePublicIdentifierSingleQuoted:function(){var t=this.consume();"'"===t?this.transitionTo("afterDoctypePublicIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypePublicIdentifier&&this.delegate.appendToDoctypePublicIdentifier(t)},afterDoctypePublicIdentifier:function(){var t=this.consume();p(t)?this.transitionTo("betweenDoctypePublicAndSystemIdentifiers"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):'"'===t?this.transitionTo("doctypeSystemIdentifierDoubleQuoted"):"'"===t&&this.transitionTo("doctypeSystemIdentifierSingleQuoted")},betweenDoctypePublicAndSystemIdentifiers:function(){var t=this.consume();p(t)||(">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):'"'===t?this.transitionTo("doctypeSystemIdentifierDoubleQuoted"):"'"===t&&this.transitionTo("doctypeSystemIdentifierSingleQuoted"))},doctypeSystemIdentifierDoubleQuoted:function(){var t=this.consume();'"'===t?this.transitionTo("afterDoctypeSystemIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypeSystemIdentifier&&this.delegate.appendToDoctypeSystemIdentifier(t)},doctypeSystemIdentifierSingleQuoted:function(){var t=this.consume();"'"===t?this.transitionTo("afterDoctypeSystemIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypeSystemIdentifier&&this.delegate.appendToDoctypeSystemIdentifier(t)},afterDoctypeSystemIdentifier:function(){var t=this.consume();p(t)||">"===t&&(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData"))},commentStart:function(){var t=this.consume();"-"===t?this.transitionTo("commentStartDash"):">"===t?(this.delegate.finishComment(),this.transitionTo("beforeData")):(this.delegate.appendToCommentData(t),this.transitionTo("comment"))},commentStartDash:function(){var t=this.consume();"-"===t?this.transitionTo("commentEnd"):">"===t?(this.delegate.finishComment(),this.transitionTo("beforeData")):(this.delegate.appendToCommentData("-"),this.transitionTo("comment"))},comment:function(){var t=this.consume();"-"===t?this.transitionTo("commentEndDash"):this.delegate.appendToCommentData(t)},commentEndDash:function(){var t=this.consume();"-"===t?this.transitionTo("commentEnd"):(this.delegate.appendToCommentData("-"+t),this.transitionTo("comment"))},commentEnd:function(){var t=this.consume();">"===t?(this.delegate.finishComment(),this.transitionTo("beforeData")):(this.delegate.appendToCommentData("--"+t),this.transitionTo("comment"))},tagName:function(){var t=this.consume();p(t)?this.transitionTo("beforeAttributeName"):"/"===t?this.transitionTo("selfClosingStartTag"):">"===t?(this.delegate.finishTag(),this.transitionTo("beforeData")):this.appendToTagName(t)},endTagName:function(){var t=this.consume();p(t)?(this.transitionTo("beforeAttributeName"),this.tagNameBuffer=""):"/"===t?(this.transitionTo("selfClosingStartTag"),this.tagNameBuffer=""):">"===t?(this.delegate.finishTag(),this.transitionTo("beforeData"),this.tagNameBuffer=""):this.appendToTagName(t)},beforeAttributeName:function(){var t=this.peek();p(t)?this.consume():"/"===t?(this.transitionTo("selfClosingStartTag"),this.consume()):">"===t?(this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):"="===t?(this.delegate.reportSyntaxError("attribute name cannot start with equals sign"),this.transitionTo("attributeName"),this.delegate.beginAttribute(),this.consume(),this.delegate.appendToAttributeName(t)):(this.transitionTo("attributeName"),this.delegate.beginAttribute())},attributeName:function(){var t=this.peek();p(t)?(this.transitionTo("afterAttributeName"),this.consume()):"/"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("selfClosingStartTag")):"="===t?(this.transitionTo("beforeAttributeValue"),this.consume()):">"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):'"'===t||"'"===t||"<"===t?(this.delegate.reportSyntaxError(t+" is not a valid character within attribute names"),this.consume(),this.delegate.appendToAttributeName(t)):(this.consume(),this.delegate.appendToAttributeName(t))},afterAttributeName:function(){var t=this.peek();p(t)?this.consume():"/"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("selfClosingStartTag")):"="===t?(this.consume(),this.transitionTo("beforeAttributeValue")):">"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.transitionTo("attributeName"),this.delegate.beginAttribute(),this.consume(),this.delegate.appendToAttributeName(t))},beforeAttributeValue:function(){var t=this.peek();p(t)?this.consume():'"'===t?(this.transitionTo("attributeValueDoubleQuoted"),this.delegate.beginAttributeValue(!0),this.consume()):"'"===t?(this.transitionTo("attributeValueSingleQuoted"),this.delegate.beginAttributeValue(!0),this.consume()):">"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):(this.transitionTo("attributeValueUnquoted"),this.delegate.beginAttributeValue(!1),this.consume(),this.delegate.appendToAttributeValue(t))},attributeValueDoubleQuoted:function(){var t=this.consume();'"'===t?(this.delegate.finishAttributeValue(),this.transitionTo("afterAttributeValueQuoted")):"&"===t?this.delegate.appendToAttributeValue(this.consumeCharRef()||"&"):this.delegate.appendToAttributeValue(t)},attributeValueSingleQuoted:function(){var t=this.consume();"'"===t?(this.delegate.finishAttributeValue(),this.transitionTo("afterAttributeValueQuoted")):"&"===t?this.delegate.appendToAttributeValue(this.consumeCharRef()||"&"):this.delegate.appendToAttributeValue(t)},attributeValueUnquoted:function(){var t=this.peek();p(t)?(this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("beforeAttributeName")):"/"===t?(this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("selfClosingStartTag")):"&"===t?(this.consume(),this.delegate.appendToAttributeValue(this.consumeCharRef()||"&")):">"===t?(this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):(this.consume(),this.delegate.appendToAttributeValue(t))},afterAttributeValueQuoted:function(){var t=this.peek();p(t)?(this.consume(),this.transitionTo("beforeAttributeName")):"/"===t?(this.consume(),this.transitionTo("selfClosingStartTag")):">"===t?(this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):this.transitionTo("beforeAttributeName")},selfClosingStartTag:function(){">"===this.peek()?(this.consume(),this.delegate.markTagAsSelfClosing(),this.delegate.finishTag(),this.transitionTo("beforeData")):this.transitionTo("beforeAttributeName")},endTagOpen:function(){var t=this.consume();("@"===t||":"===t||d(t))&&(this.transitionTo("endTagName"),this.tagNameBuffer="",this.delegate.beginEndTag(),this.appendToTagName(t))}},this.reset()}return t.prototype.reset=function(){this.transitionTo("beforeData"),this.input="",this.tagNameBuffer="",this.index=0,this.line=1,this.column=0,this.delegate.reset()},t.prototype.transitionTo=function(t){this.state=t},t.prototype.tokenize=function(t){this.reset(),this.tokenizePart(t),this.tokenizeEOF()},t.prototype.tokenizePart=function(t){for(this.input+=function(t){return t.replace(c,"\n")}(t);this.index<this.input.length;){var e=this.states[this.state];if(void 0===e)throw new Error("unhandled state "+this.state);e.call(this)}},t.prototype.tokenizeEOF=function(){this.flushData()},t.prototype.flushData=function(){"data"===this.state&&(this.delegate.finishData(),this.transitionTo("beforeData"))},t.prototype.peek=function(){return this.input.charAt(this.index)},t.prototype.consume=function(){var t=this.peek();return this.index++,"\n"===t?(this.line++,this.column=0):this.column++,t},t.prototype.consumeCharRef=function(){var t=this.input.indexOf(";",this.index);if(-1!==t){var e=this.input.slice(this.index,t),i=this.entityParser.parse(e);if(i){for(var n=e.length;n;)this.consume(),n--;return this.consume(),i}}},t.prototype.markTagStart=function(){this.delegate.tagOpen()},t.prototype.appendToTagName=function(t){this.tagNameBuffer+=t,this.delegate.appendToTagName(t)},t.prototype.isIgnoredEndTag=function(){var t=this.tagNameBuffer;return"title"===t&&"</title>"!==this.input.substring(this.index,this.index+8)||"style"===t&&"</style>"!==this.input.substring(this.index,this.index+8)||"script"===t&&"<\/script>"!==this.input.substring(this.index,this.index+9)},t}(),l=function(){function t(t,e){void 0===e&&(e={}),this.options=e,this.token=null,this.startLine=1,this.startColumn=0,this.tokens=[],this.tokenizer=new f(this,t,e.mode),this._currentAttribute=void 0}return t.prototype.tokenize=function(t){return this.tokens=[],this.tokenizer.tokenize(t),this.tokens},t.prototype.tokenizePart=function(t){return this.tokens=[],this.tokenizer.tokenizePart(t),this.tokens},t.prototype.tokenizeEOF=function(){return this.tokens=[],this.tokenizer.tokenizeEOF(),this.tokens[0]},t.prototype.reset=function(){this.token=null,this.startLine=1,this.startColumn=0},t.prototype.current=function(){var t=this.token;if(null===t)throw new Error("token was unexpectedly null");if(0===arguments.length)return t;for(var e=0;e<arguments.length;e++)if(t.type===arguments[e])return t;throw new Error("token type was unexpectedly "+t.type)},t.prototype.push=function(t){this.token=t,this.tokens.push(t)},t.prototype.currentAttribute=function(){return this._currentAttribute},t.prototype.addLocInfo=function(){this.options.loc&&(this.current().loc={start:{line:this.startLine,column:this.startColumn},end:{line:this.tokenizer.line,column:this.tokenizer.column}}),this.startLine=this.tokenizer.line,this.startColumn=this.tokenizer.column},t.prototype.beginDoctype=function(){this.push({type:"Doctype",name:""})},t.prototype.appendToDoctypeName=function(t){this.current("Doctype").name+=t},t.prototype.appendToDoctypePublicIdentifier=function(t){var e=this.current("Doctype");void 0===e.publicIdentifier?e.publicIdentifier=t:e.publicIdentifier+=t},t.prototype.appendToDoctypeSystemIdentifier=function(t){var e=this.current("Doctype");void 0===e.systemIdentifier?e.systemIdentifier=t:e.systemIdentifier+=t},t.prototype.endDoctype=function(){this.addLocInfo()},t.prototype.beginData=function(){this.push({type:"Chars",chars:""})},t.prototype.appendToData=function(t){this.current("Chars").chars+=t},t.prototype.finishData=function(){this.addLocInfo()},t.prototype.beginComment=function(){this.push({type:"Comment",chars:""})},t.prototype.appendToCommentData=function(t){this.current("Comment").chars+=t},t.prototype.finishComment=function(){this.addLocInfo()},t.prototype.tagOpen=function(){},t.prototype.beginStartTag=function(){this.push({type:"StartTag",tagName:"",attributes:[],selfClosing:!1})},t.prototype.beginEndTag=function(){this.push({type:"EndTag",tagName:""})},t.prototype.finishTag=function(){this.addLocInfo()},t.prototype.markTagAsSelfClosing=function(){this.current("StartTag").selfClosing=!0},t.prototype.appendToTagName=function(t){this.current("StartTag","EndTag").tagName+=t},t.prototype.beginAttribute=function(){this._currentAttribute=["","",!1]},t.prototype.appendToAttributeName=function(t){this.currentAttribute()[0]+=t},t.prototype.beginAttributeValue=function(t){this.currentAttribute()[2]=t},t.prototype.appendToAttributeValue=function(t){this.currentAttribute()[1]+=t},t.prototype.finishAttributeValue=function(){this.current("StartTag").attributes.push(this._currentAttribute)},t.prototype.reportSyntaxError=function(t){this.current().syntaxError=t},t}();function m(t,e){return new l(new r(n),e).tokenize(t)}var g=i.Options,b="StartTag",T="EndTag",y="Chars",D="Comment",v="Doctype";function A(t,e){for(var n=i.tokenize(t),s=[],o=0;o<n.length;o++){var a=n[o];if("nl"===a.t&&e.nl2br)s.push({type:b,tagName:"br",attributes:[],selfClosing:!0});else if(a.isLink&&e.check(a)){var r=e.resolve(a),h=r.formatted,u=r.formattedHref,c=r.tagName,p=r.className,d=r.target,f=r.rel,l=r.attributes,m=r.truncate,g=[["href",u]];for(var D in p&&g.push(["class",p]),d&&g.push(["target",d]),f&&g.push(["rel",f]),m&&h.length>m&&(h=h.substring(0,m)+"…"),l)g.push([D,l[D]]);s.push({type:b,tagName:c,attributes:g,selfClosing:!1}),s.push({type:y,chars:h}),s.push({type:T,tagName:c})}else s.push({type:y,chars:a.toString()})}return s}function k(t,e,i,n){for(var s=1;i<e.length&&s>0;){var o=e[i];o.type===b&&o.tagName.toUpperCase()===t?s++:o.type===T&&o.tagName.toUpperCase()===t&&s--,n.push(o),i++}return n}function N(t){for(var e=[],i=0;i<t.length;i++){var n=t[i][0],s=t[i][1];e.push("".concat(n,'="').concat(s.replace(/"/g,"&quot;"),'"'))}return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=m(t),n=[],s=[];e=new g(e);for(var o=0;o<i.length;o++){var a=i[o];if(a.type!==b)if(a.type===y){var r=A(a.chars,e);n.push.apply(n,r)}else n.push(a);else{n.push(a);var h=a.tagName.toUpperCase(),u="A"===h||e.ignoreTags.indexOf(h)>=0;if(!u)continue;var c=n.length;k(h,i,++o,n),o+=n.length-c-1}}for(var p=0;p<n.length;p++){var d=n[p];switch(d.type){case b:var f="<"+d.tagName;if(d.attributes.length>0){var l=N(d.attributes);f+=" "+l.join(" ")}f+=">",s.push(f);break;case T:s.push("</".concat(d.tagName,">"));break;case y:s.push(d.chars);break;case D:s.push("\x3c!--".concat(d.chars,"--\x3e"));break;case v:var C="<!DOCTYPE ".concat(d.name);d.publicIdentifier&&(C+=' PUBLIC "'.concat(d.publicIdentifier,'"')),d.systemIdentifier&&(C+=' "'.concat(d.systemIdentifier,'"')),C+=">",s.push(C)}}return s.join("")}}(linkify);
var linkifyHtml=function(t){"use strict";function e(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var i=e(t),n={nbsp:" "},s=/^#[xX]([A-Fa-f0-9]+)$/,o=/^#([0-9]+)$/,a=/^([A-Za-z0-9]+)$/,r=function(){function t(t){this.named=t}return t.prototype.parse=function(t){if(t){var e=t.match(s);return e?"&#x"+e[1]+";":(e=t.match(o))?"&#"+e[1]+";":(e=t.match(a))?this.named[e[1]]||"&"+e[1]+";":void 0}},t}(),h=/[\t\n\f ]/,u=/[A-Za-z]/,c=/\r\n?/g;function p(t){return h.test(t)}function d(t){return u.test(t)}var f=function(){function t(t,e,i){void 0===i&&(i="precompile"),this.delegate=t,this.entityParser=e,this.mode=i,this.state="beforeData",this.line=-1,this.column=-1,this.input="",this.index=-1,this.tagNameBuffer="",this.states={beforeData:function(){var t=this.peek();if("<"!==t||this.isIgnoredEndTag()){if("precompile"===this.mode&&"\n"===t){var e=this.tagNameBuffer.toLowerCase();"pre"!==e&&"textarea"!==e||this.consume()}this.transitionTo("data"),this.delegate.beginData()}else this.transitionTo("tagOpen"),this.markTagStart(),this.consume()},data:function(){var t=this.peek(),e=this.tagNameBuffer;"<"!==t||this.isIgnoredEndTag()?"&"===t&&"script"!==e&&"style"!==e?(this.consume(),this.delegate.appendToData(this.consumeCharRef()||"&")):(this.consume(),this.delegate.appendToData(t)):(this.delegate.finishData(),this.transitionTo("tagOpen"),this.markTagStart(),this.consume())},tagOpen:function(){var t=this.consume();"!"===t?this.transitionTo("markupDeclarationOpen"):"/"===t?this.transitionTo("endTagOpen"):("@"===t||":"===t||d(t))&&(this.transitionTo("tagName"),this.tagNameBuffer="",this.delegate.beginStartTag(),this.appendToTagName(t))},markupDeclarationOpen:function(){var t=this.consume();"-"===t&&"-"===this.peek()?(this.consume(),this.transitionTo("commentStart"),this.delegate.beginComment()):"DOCTYPE"===t.toUpperCase()+this.input.substring(this.index,this.index+6).toUpperCase()&&(this.consume(),this.consume(),this.consume(),this.consume(),this.consume(),this.consume(),this.transitionTo("doctype"),this.delegate.beginDoctype&&this.delegate.beginDoctype())},doctype:function(){p(this.consume())&&this.transitionTo("beforeDoctypeName")},beforeDoctypeName:function(){var t=this.consume();p(t)||(this.transitionTo("doctypeName"),this.delegate.appendToDoctypeName&&this.delegate.appendToDoctypeName(t.toLowerCase()))},doctypeName:function(){var t=this.consume();p(t)?this.transitionTo("afterDoctypeName"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypeName&&this.delegate.appendToDoctypeName(t.toLowerCase())},afterDoctypeName:function(){var t=this.consume();if(!p(t))if(">"===t)this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData");else{var e=t.toUpperCase()+this.input.substring(this.index,this.index+5).toUpperCase(),i="PUBLIC"===e.toUpperCase(),n="SYSTEM"===e.toUpperCase();(i||n)&&(this.consume(),this.consume(),this.consume(),this.consume(),this.consume(),this.consume()),i?this.transitionTo("afterDoctypePublicKeyword"):n&&this.transitionTo("afterDoctypeSystemKeyword")}},afterDoctypePublicKeyword:function(){var t=this.peek();p(t)?(this.transitionTo("beforeDoctypePublicIdentifier"),this.consume()):'"'===t?(this.transitionTo("doctypePublicIdentifierDoubleQuoted"),this.consume()):"'"===t?(this.transitionTo("doctypePublicIdentifierSingleQuoted"),this.consume()):">"===t&&(this.consume(),this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData"))},doctypePublicIdentifierDoubleQuoted:function(){var t=this.consume();'"'===t?this.transitionTo("afterDoctypePublicIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypePublicIdentifier&&this.delegate.appendToDoctypePublicIdentifier(t)},doctypePublicIdentifierSingleQuoted:function(){var t=this.consume();"'"===t?this.transitionTo("afterDoctypePublicIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypePublicIdentifier&&this.delegate.appendToDoctypePublicIdentifier(t)},afterDoctypePublicIdentifier:function(){var t=this.consume();p(t)?this.transitionTo("betweenDoctypePublicAndSystemIdentifiers"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):'"'===t?this.transitionTo("doctypeSystemIdentifierDoubleQuoted"):"'"===t&&this.transitionTo("doctypeSystemIdentifierSingleQuoted")},betweenDoctypePublicAndSystemIdentifiers:function(){var t=this.consume();p(t)||(">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):'"'===t?this.transitionTo("doctypeSystemIdentifierDoubleQuoted"):"'"===t&&this.transitionTo("doctypeSystemIdentifierSingleQuoted"))},doctypeSystemIdentifierDoubleQuoted:function(){var t=this.consume();'"'===t?this.transitionTo("afterDoctypeSystemIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypeSystemIdentifier&&this.delegate.appendToDoctypeSystemIdentifier(t)},doctypeSystemIdentifierSingleQuoted:function(){var t=this.consume();"'"===t?this.transitionTo("afterDoctypeSystemIdentifier"):">"===t?(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData")):this.delegate.appendToDoctypeSystemIdentifier&&this.delegate.appendToDoctypeSystemIdentifier(t)},afterDoctypeSystemIdentifier:function(){var t=this.consume();p(t)||">"===t&&(this.delegate.endDoctype&&this.delegate.endDoctype(),this.transitionTo("beforeData"))},commentStart:function(){var t=this.consume();"-"===t?this.transitionTo("commentStartDash"):">"===t?(this.delegate.finishComment(),this.transitionTo("beforeData")):(this.delegate.appendToCommentData(t),this.transitionTo("comment"))},commentStartDash:function(){var t=this.consume();"-"===t?this.transitionTo("commentEnd"):">"===t?(this.delegate.finishComment(),this.transitionTo("beforeData")):(this.delegate.appendToCommentData("-"),this.transitionTo("comment"))},comment:function(){var t=this.consume();"-"===t?this.transitionTo("commentEndDash"):this.delegate.appendToCommentData(t)},commentEndDash:function(){var t=this.consume();"-"===t?this.transitionTo("commentEnd"):(this.delegate.appendToCommentData("-"+t),this.transitionTo("comment"))},commentEnd:function(){var t=this.consume();">"===t?(this.delegate.finishComment(),this.transitionTo("beforeData")):(this.delegate.appendToCommentData("--"+t),this.transitionTo("comment"))},tagName:function(){var t=this.consume();p(t)?this.transitionTo("beforeAttributeName"):"/"===t?this.transitionTo("selfClosingStartTag"):">"===t?(this.delegate.finishTag(),this.transitionTo("beforeData")):this.appendToTagName(t)},endTagName:function(){var t=this.consume();p(t)?(this.transitionTo("beforeAttributeName"),this.tagNameBuffer=""):"/"===t?(this.transitionTo("selfClosingStartTag"),this.tagNameBuffer=""):">"===t?(this.delegate.finishTag(),this.transitionTo("beforeData"),this.tagNameBuffer=""):this.appendToTagName(t)},beforeAttributeName:function(){var t=this.peek();p(t)?this.consume():"/"===t?(this.transitionTo("selfClosingStartTag"),this.consume()):">"===t?(this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):"="===t?(this.delegate.reportSyntaxError("attribute name cannot start with equals sign"),this.transitionTo("attributeName"),this.delegate.beginAttribute(),this.consume(),this.delegate.appendToAttributeName(t)):(this.transitionTo("attributeName"),this.delegate.beginAttribute())},attributeName:function(){var t=this.peek();p(t)?(this.transitionTo("afterAttributeName"),this.consume()):"/"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("selfClosingStartTag")):"="===t?(this.transitionTo("beforeAttributeValue"),this.consume()):">"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):'"'===t||"'"===t||"<"===t?(this.delegate.reportSyntaxError(t+" is not a valid character within attribute names"),this.consume(),this.delegate.appendToAttributeName(t)):(this.consume(),this.delegate.appendToAttributeName(t))},afterAttributeName:function(){var t=this.peek();p(t)?this.consume():"/"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("selfClosingStartTag")):"="===t?(this.consume(),this.transitionTo("beforeAttributeValue")):">"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.transitionTo("attributeName"),this.delegate.beginAttribute(),this.consume(),this.delegate.appendToAttributeName(t))},beforeAttributeValue:function(){var t=this.peek();p(t)?this.consume():'"'===t?(this.transitionTo("attributeValueDoubleQuoted"),this.delegate.beginAttributeValue(!0),this.consume()):"'"===t?(this.transitionTo("attributeValueSingleQuoted"),this.delegate.beginAttributeValue(!0),this.consume()):">"===t?(this.delegate.beginAttributeValue(!1),this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):(this.transitionTo("attributeValueUnquoted"),this.delegate.beginAttributeValue(!1),this.consume(),this.delegate.appendToAttributeValue(t))},attributeValueDoubleQuoted:function(){var t=this.consume();'"'===t?(this.delegate.finishAttributeValue(),this.transitionTo("afterAttributeValueQuoted")):"&"===t?this.delegate.appendToAttributeValue(this.consumeCharRef()||"&"):this.delegate.appendToAttributeValue(t)},attributeValueSingleQuoted:function(){var t=this.consume();"'"===t?(this.delegate.finishAttributeValue(),this.transitionTo("afterAttributeValueQuoted")):"&"===t?this.delegate.appendToAttributeValue(this.consumeCharRef()||"&"):this.delegate.appendToAttributeValue(t)},attributeValueUnquoted:function(){var t=this.peek();p(t)?(this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("beforeAttributeName")):"/"===t?(this.delegate.finishAttributeValue(),this.consume(),this.transitionTo("selfClosingStartTag")):"&"===t?(this.consume(),this.delegate.appendToAttributeValue(this.consumeCharRef()||"&")):">"===t?(this.delegate.finishAttributeValue(),this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):(this.consume(),this.delegate.appendToAttributeValue(t))},afterAttributeValueQuoted:function(){var t=this.peek();p(t)?(this.consume(),this.transitionTo("beforeAttributeName")):"/"===t?(this.consume(),this.transitionTo("selfClosingStartTag")):">"===t?(this.consume(),this.delegate.finishTag(),this.transitionTo("beforeData")):this.transitionTo("beforeAttributeName")},selfClosingStartTag:function(){">"===this.peek()?(this.consume(),this.delegate.markTagAsSelfClosing(),this.delegate.finishTag(),this.transitionTo("beforeData")):this.transitionTo("beforeAttributeName")},endTagOpen:function(){var t=this.consume();("@"===t||":"===t||d(t))&&(this.transitionTo("endTagName"),this.tagNameBuffer="",this.delegate.beginEndTag(),this.appendToTagName(t))}},this.reset()}return t.prototype.reset=function(){this.transitionTo("beforeData"),this.input="",this.tagNameBuffer="",this.index=0,this.line=1,this.column=0,this.delegate.reset()},t.prototype.transitionTo=function(t){this.state=t},t.prototype.tokenize=function(t){this.reset(),this.tokenizePart(t),this.tokenizeEOF()},t.prototype.tokenizePart=function(t){for(this.input+=function(t){return t.replace(c,"\n")}(t);this.index<this.input.length;){var e=this.states[this.state];if(void 0===e)throw new Error("unhandled state "+this.state);e.call(this)}},t.prototype.tokenizeEOF=function(){this.flushData()},t.prototype.flushData=function(){"data"===this.state&&(this.delegate.finishData(),this.transitionTo("beforeData"))},t.prototype.peek=function(){return this.input.charAt(this.index)},t.prototype.consume=function(){var t=this.peek();return this.index++,"\n"===t?(this.line++,this.column=0):this.column++,t},t.prototype.consumeCharRef=function(){var t=this.input.indexOf(";",this.index);if(-1!==t){var e=this.input.slice(this.index,t),i=this.entityParser.parse(e);if(i){for(var n=e.length;n;)this.consume(),n--;return this.consume(),i}}},t.prototype.markTagStart=function(){this.delegate.tagOpen()},t.prototype.appendToTagName=function(t){this.tagNameBuffer+=t,this.delegate.appendToTagName(t)},t.prototype.isIgnoredEndTag=function(){var t=this.tagNameBuffer;return"title"===t&&"</title>"!==this.input.substring(this.index,this.index+8)||"style"===t&&"</style>"!==this.input.substring(this.index,this.index+8)||"script"===t&&"<\/script>"!==this.input.substring(this.index,this.index+9)},t}(),l=function(){function t(t,e){void 0===e&&(e={}),this.options=e,this.token=null,this.startLine=1,this.startColumn=0,this.tokens=[],this.tokenizer=new f(this,t,e.mode),this._currentAttribute=void 0}return t.prototype.tokenize=function(t){return this.tokens=[],this.tokenizer.tokenize(t),this.tokens},t.prototype.tokenizePart=function(t){return this.tokens=[],this.tokenizer.tokenizePart(t),this.tokens},t.prototype.tokenizeEOF=function(){return this.tokens=[],this.tokenizer.tokenizeEOF(),this.tokens[0]},t.prototype.reset=function(){this.token=null,this.startLine=1,this.startColumn=0},t.prototype.current=function(){var t=this.token;if(null===t)throw new Error("token was unexpectedly null");if(0===arguments.length)return t;for(var e=0;e<arguments.length;e++)if(t.type===arguments[e])return t;throw new Error("token type was unexpectedly "+t.type)},t.prototype.push=function(t){this.token=t,this.tokens.push(t)},t.prototype.currentAttribute=function(){return this._currentAttribute},t.prototype.addLocInfo=function(){this.options.loc&&(this.current().loc={start:{line:this.startLine,column:this.startColumn},end:{line:this.tokenizer.line,column:this.tokenizer.column}}),this.startLine=this.tokenizer.line,this.startColumn=this.tokenizer.column},t.prototype.beginDoctype=function(){this.push({type:"Doctype",name:""})},t.prototype.appendToDoctypeName=function(t){this.current("Doctype").name+=t},t.prototype.appendToDoctypePublicIdentifier=function(t){var e=this.current("Doctype");void 0===e.publicIdentifier?e.publicIdentifier=t:e.publicIdentifier+=t},t.prototype.appendToDoctypeSystemIdentifier=function(t){var e=this.current("Doctype");void 0===e.systemIdentifier?e.systemIdentifier=t:e.systemIdentifier+=t},t.prototype.endDoctype=function(){this.addLocInfo()},t.prototype.beginData=function(){this.push({type:"Chars",chars:""})},t.prototype.appendToData=function(t){this.current("Chars").chars+=t},t.prototype.finishData=function(){this.addLocInfo()},t.prototype.beginComment=function(){this.push({type:"Comment",chars:""})},t.prototype.appendToCommentData=function(t){this.current("Comment").chars+=t},t.prototype.finishComment=function(){this.addLocInfo()},t.prototype.tagOpen=function(){},t.prototype.beginStartTag=function(){this.push({type:"StartTag",tagName:"",attributes:[],selfClosing:!1})},t.prototype.beginEndTag=function(){this.push({type:"EndTag",tagName:""})},t.prototype.finishTag=function(){this.addLocInfo()},t.prototype.markTagAsSelfClosing=function(){this.current("StartTag").selfClosing=!0},t.prototype.appendToTagName=function(t){this.current("StartTag","EndTag").tagName+=t},t.prototype.beginAttribute=function(){this._currentAttribute=["","",!1]},t.prototype.appendToAttributeName=function(t){this.currentAttribute()[0]+=t},t.prototype.beginAttributeValue=function(t){this.currentAttribute()[2]=t},t.prototype.appendToAttributeValue=function(t){this.currentAttribute()[1]+=t},t.prototype.finishAttributeValue=function(){this.current("StartTag").attributes.push(this._currentAttribute)},t.prototype.reportSyntaxError=function(t){this.current().syntaxError=t},t}();function m(t,e){return new l(new r(n),e).tokenize(t)}var g=i.Options,b="StartTag",T="EndTag",y="Chars",D="Comment",v="Doctype";function A(t,e){for(var n=i.tokenize(t),s=[],o=0;o<n.length;o++){var a=n[o];if("nl"===a.t&&e.nl2br)s.push({type:b,tagName:"br",attributes:[],selfClosing:!0});else if(a.isLink&&e.check(a)){var r=e.resolve(a),h=r.formatted,u=r.formattedHref,c=r.tagName,p=r.className,d=r.target,f=r.rel,l=r.attributes,m=r.truncate,g=[["href",u]];for(var D in p&&g.push(["class",p]),d&&g.push(["target",d]),f&&g.push(["rel",f]),m&&h.length>m&&(h=h.substring(0,m)+"…"),l)g.push([D,l[D]]);s.push({type:b,tagName:c,attributes:g,selfClosing:!1}),s.push({type:y,chars:h}),s.push({type:T,tagName:c})}else s.push({type:y,chars:a.toString()})}return s}function k(t,e,i,n){for(var s=1;i<e.length&&s>0;){var o=e[i];o.type===b&&o.tagName.toUpperCase()===t?s++:o.type===T&&o.tagName.toUpperCase()===t&&s--,n.push(o),i++}return n}function N(t){for(var e=[],i=0;i<t.length;i++){var n=t[i][0],s=t[i][1];e.push("".concat(n,'="').concat(s.replace(/"/g,"&quot;"),'"'))}return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=m(t),n=[],s=[];e=new g(e);for(var o=0;o<i.length;o++){var a=i[o];if(a.type!==b)if(a.type===y){var r=A(a.chars,e);n.push.apply(n,r)}else n.push(a);else{n.push(a);var h=a.tagName.toUpperCase(),u="A"===h||e.ignoreTags.indexOf(h)>=0;if(!u)continue;var c=n.length;k(h,i,++o,n),o+=n.length-c-1}}for(var p=0;p<n.length;p++){var d=n[p];switch(d.type){case b:var f="<"+d.tagName;if(d.attributes.length>0){var l=N(d.attributes);f+=" "+l.join(" ")}f+=">",s.push(f);break;case T:s.push("</".concat(d.tagName,">"));break;case y:s.push(d.chars);break;case D:s.push("\x3c!--".concat(d.chars,"--\x3e"));break;case v:var C="<!DOCTYPE ".concat(d.name);d.publicIdentifier&&(C+=' PUBLIC "'.concat(d.publicIdentifier,'"')),d.systemIdentifier&&(C+=' "'.concat(d.systemIdentifier,'"')),C+=">",s.push(C)}}return s.join("")}}(linkify);

@@ -11,8 +11,4 @@ import * as linkify from 'linkifyjs';

// whitespace is parsed properly. Other types of whitespace should already
// be accounted for. &gt; &lt; and &quot; are also frequently relevant ones
amp: "&",
gt: ">",
lt: "<",
nbsp: " ",
quot: "\""
// be accounted for
nbsp: " "
};

@@ -38,3 +34,3 @@ var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/;

if (matches) {
return String.fromCharCode(parseInt(matches[1], 16));
return "&#x" + matches[1] + ";";
}

@@ -45,3 +41,3 @@

if (matches) {
return String.fromCharCode(parseInt(matches[1], 10));
return "&#" + matches[1] + ";";
}

@@ -48,0 +44,0 @@

@@ -33,8 +33,4 @@ 'use strict';

// whitespace is parsed properly. Other types of whitespace should already
// be accounted for. &gt; &lt; and &quot; are also frequently relevant ones
amp: "&",
gt: ">",
lt: "<",
nbsp: " ",
quot: "\""
// be accounted for
nbsp: " "
};

@@ -60,3 +56,3 @@ var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/;

if (matches) {
return String.fromCharCode(parseInt(matches[1], 16));
return "&#x" + matches[1] + ";";
}

@@ -67,3 +63,3 @@

if (matches) {
return String.fromCharCode(parseInt(matches[1], 10));
return "&#" + matches[1] + ";";
}

@@ -70,0 +66,0 @@

{
"name": "linkifyjs",
"version": "3.0.4",
"version": "3.0.5",
"description": "Find URLs, email addresses, #hashtags and @mentions in plain-text strings, then convert them into HTML <a> links.",

@@ -38,4 +38,4 @@ "main": "index.js",

"devDependencies": {
"@nfrasser/simple-html-tokenizer": "^0.5.11-1"
"@nfrasser/simple-html-tokenizer": "==0.5.11-1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc