From 7d9a3ccb38f1fc3ee9dc3534fb9d10ff5d4c7e29 Mon Sep 17 00:00:00 2001 From: Aria Buckles Date: Thu, 7 Jan 2021 19:08:30 -0800 Subject: [PATCH] Strikethrough: fix exponential backtracking A long sequence of backslashes inside a strikethrough could confuse the strikethrough regex into exponential backtracking, causing a potential ReDoS vulnerability. This commit updates the strikethrough regex to only accept a backslash if it is preceding an escaped character, as other rules handle backslashes. Updates to version 0.7.3 to publish this fix. Thanks to @pwntester and the [GitHub Security Lab team](https://securitylab.github.com/) for finding this vulnerability! Test plan: 1. `make test` * verify the new strikethrough backtracking test passes * verify all the prior tests pass --- __tests__/simple-markdown-test.js | 10 ++++++++++ package-lock.json | 2 +- package.json | 2 +- simple-markdown.js | 2 +- simple-markdown.min.js | 2 +- src/index.js | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/__tests__/simple-markdown-test.js b/__tests__/simple-markdown-test.js index b637f83..a275e86 100644 --- a/__tests__/simple-markdown-test.js +++ b/__tests__/simple-markdown-test.js @@ -4414,5 +4414,15 @@ describe("simple markdown", function() { var duration = Date.now() - startTime; assert.ok(duration < 10, "Expected parsing to finish in <10ms, but was " + duration + "ms."); }); + + it("should parse long strikethroughs with lots of backslasher quickly", function() { + var source = "~~\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}\\}" + + "\\}\\}\\}\\}\\}\\}\\}\\}\\\\}\\}\\}\\}\\}\\}\\}}\\}\\}\\}\\}\\}\\}}~"; + + var startTime = Date.now(); + var parsed = blockParse(source); + var duration = Date.now() - startTime; + assert.ok(duration < 10, "Expected parsing to finish in <10ms, but was " + duration + "ms."); + }); }); }); diff --git a/package-lock.json b/package-lock.json index ff18deb..e5012a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "simple-markdown", - "version": "0.7.1", + "version": "0.7.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index edbd3ad..899b544 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-markdown", - "version": "0.7.2", + "version": "0.7.3", "description": "Javascript markdown parsing, made simple", "main": "simple-markdown.js", "types": "simple-markdown.d.ts", diff --git a/simple-markdown.js b/simple-markdown.js index 3a86f28..d2dbac2 100644 --- a/simple-markdown.js +++ b/simple-markdown.js @@ -1700,7 +1700,7 @@ var defaultRules /* : DefaultRules */ = { }, del: { order: currOrder++, - match: inlineRegex(/^~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s~]|\s(?!~~))+?)~~/), + match: inlineRegex(/^~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s~\\]|\s(?!~~))+?)~~/), parse: parseCaptureInline, react: function(node, output, state) { return reactElement( diff --git a/simple-markdown.min.js b/simple-markdown.min.js index daf0609..2a2ef46 100644 --- a/simple-markdown.min.js +++ b/simple-markdown.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).SimpleMarkdown=e()}(this,function(){"use strict";function r(t){return t.replace(k,"\n").replace(x,"").replace(w," ")}function c(t,e){var n=t||{};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function t(m,n){var y,g=Object.keys(m).filter(function(t){var e=m[t];if(null==e||null==e.match)return!1;var n=e.order;return"number"==typeof n&&isFinite(n)||"undefined"==typeof console||console.warn("simple-markdown: Invalid order for rule `"+t+"`: "+String(n)),!0});g.sort(function(t,e){var n=m[t],r=m[e],o=n.order,u=r.order;if(o!==u)return o-u;var a=n.quality?0:1,l=r.quality?0:1;return a!=l?a-l:t";return r?l+e+"":l}function u(t){if(null==t)return null;try{var e=decodeURIComponent(t).replace(/[^A-Za-z0-9/:]/g,"").toLowerCase();if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}catch(t){return null}return t}function l(t){return t.replace(A,"$1")}function f(t,e,n){var r=n.inline||!1;n.inline=!0;var o=t(e,n);return n.inline=r,o}function p(t,e,n){return{content:f(e,t[1],n)}}function s(){return{}}function d(t){return String(t).replace(E,function(t){return S[t]})}var h,m,y,g,v,k=/\r\n?/g,w=/\t/g,x=/\f/g,b="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,_={},E=/[<>&"']/g,S={"<":"<",">":">","&":"&",'"':""","'":"'","/":"/","`":"`"},A=/\\([^0-9A-Za-z\s])/g,R="(?:[*+-]|\\d+\\.)",$="( *)("+R+") +",O=new RegExp("^"+$),T=new RegExp($+"[^\\n]*(?:\\n(?!\\1"+R+" )[^\\n]*)*(\n|$)","gm"),j=/\n{2,}$/,C=/^ (?= *`)|(` *) $/g,P=j,q=/ *\n+$/,F=new RegExp("^( *)("+R+") [\\s\\S]+?(?:\n{2,}(?! )(?!\\1"+R+" )\\n*|\\s*\n*$)"),B=/(?:^|\n)( *)$/,N=(h=/^ *\| *| *\| *$/g,m=/ *$/,y=/^ *-+: *$/,g=/^ *:-+: *$/,v=/^ *:-+ *$/,{parseTable:z(!0),parseNpTable:z(!1),TABLE_REGEX:/^ *(\|.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/,NPTABLE_REGEX:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/});function I(t){return y.test(t)?"right":g.test(t)?"center":v.test(t)?"left":null}function L(t,e,n,r){var o=n.inTable;n.inTable=!0;var u=e(t.trim(),n);n.inTable=o;var a=[[]];return u.forEach(function(t,e){"tableSeparator"===t.type?r&&(0===e||e===u.length-1)||a.push([]):("text"!==t.type||null!=u[e+1]&&"tableSeparator"!==u[e+1].type||(t.content=t.content.replace(m,"")),a[a.length-1].push(t))}),a}function z(p){return function(t,e,n){n.inline=!0;var r,o,u,a,l,c=L(t[1],e,n,p),i=(l=t[2],p&&(l=l.replace(h,"")),l.trim().split("|").map(I)),f=(r=t[3],o=e,u=n,a=p,r.trim().split("\n").map(function(t){return L(t,o,u,a)}));return n.inline=!1,{type:"table",header:c,align:i,cells:f}}}function G(t,e,n){var r=(t[2]||t[1]).replace(/\s+/g," ").toLowerCase();if(e._defs&&e._defs[r]){var o=e._defs[r];n.target=o.target,n.title=o.title}return e._refs=e._refs||{},e._refs[r]=e._refs[r]||[],e._refs[r].push(n),n}function X(n,r,o){if(!r)throw new Error("simple-markdown: outputFor: `property` must be defined. if you just upgraded, you probably need to replace `outputFor` with `reactFor`");var u,t=(n.Array||K.Array)[r];if(!t)throw new Error("simple-markdown: outputFor: to join nodes of type `"+r+"` you must provide an `Array:` joiner rule with that type, Please see the docs for details on specifying an Array rule.");var a=t,l=function(t,e){return u=e=e||u,Array.isArray(t)?a(t,l,e):n[t.type][r](t,l,e)};return function(t,e){return u=c(e,o),l(t,u)}}function Z(t,e){return(e=e||{}).inline=!1,V(t,e)}function U(t,e){var n=j.test(t);return(e=e||{}).inline=!n,V(t,e)}function H(t,e){return W(Z(t,e),e)}var M="(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*",D="\\s*?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*",Q=/mailto:/i,J=0,K={Array:{react:function(t,e,n){for(var r=n.key,o=[],u=0;u"}},codeBlock:{order:J++,match:n(/^(?: [^\n]+\n*)+(?:\n *)+\n/),parse:function(t,e,n){return{lang:void 0,content:t[0].replace(/^ /gm,"").replace(/\n+$/,"")}},react:function(t,e,n){var r=t.lang?"markdown-code-"+t.lang:void 0;return a("pre",n.key,{children:a("code",null,{className:r,children:t.content})})},html:function(t,e,n){var r=t.lang?"markdown-code-"+t.lang:void 0,o=i("code",d(t.content),{class:r});return i("pre",o)}},fence:{order:J++,match:n(/^ *(`{3,}|~{3,}) *(?:(\S+) *)?\n([\s\S]+?)\n?\1 *(?:\n *)+\n/),parse:function(t,e,n){return{type:"codeBlock",lang:t[2]||void 0,content:t[3]}},react:null,html:null},blockQuote:{order:J++,match:n(/^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/),parse:function(t,e,n){return{content:e(t[0].replace(/^ *> ?/gm,""),n)}},react:function(t,e,n){return a("blockquote",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("blockquote",e(t.content,n))}},list:{order:J++,match:function(t,e){var n=null==e.prevCapture?"":e.prevCapture[0],r=B.exec(n),o=e._list||!e.inline;return r&&o?(t=r[1]+t,F.exec(t)):null},parse:function(t,s,d){var e=t[2],n=1]*)>?(?: +["(]([^\n]+)[")])? *\n(?: *\n)*/),parse:function(t,e,n){var r=t[1].replace(/\s+/g," ").toLowerCase(),o=t[2],u=t[3];return n._refs&&n._refs[r]&&n._refs[r].forEach(function(t){t.target=o,t.title=u}),n._defs=n._defs||{},n._defs[r]={target:o,title:u},{def:r,target:o,title:u}},react:function(){return null},html:function(){return""}},table:{order:J++,match:n(N.TABLE_REGEX),parse:N.parseTable,react:function(e,n,r){function o(t){return null==e.align[t]?{}:{textAlign:e.align[t]}}var t=e.header.map(function(t,e){return a("th",""+e,{style:o(e),scope:"col",children:n(t,r)})}),u=e.cells.map(function(t,e){return a("tr",""+e,{children:t.map(function(t,e){return a("td",""+e,{style:o(e),children:n(t,r)})})})});return a("table",r.key,{children:[a("thead","thead",{children:a("tr",null,{children:t})}),a("tbody","tbody",{children:u})]})},html:function(e,n,r){function o(t){return null==e.align[t]?"":"text-align:"+e.align[t]+";"}var t=e.header.map(function(t,e){return i("th",n(t,r),{style:o(e),scope:"col"})}).join(""),u=e.cells.map(function(t){var e=t.map(function(t,e){return i("td",n(t,r),{style:o(e)})}).join("");return i("tr",e)}).join(""),a=i("thead",i("tr",t)),l=i("tbody",u);return i("table",a+l)}},newline:{order:J++,match:n(/^(?:\n *)*\n/),parse:s,react:function(t,e,n){return"\n"},html:function(t,e,n){return"\n"}},paragraph:{order:J++,match:n(/^((?:[^\n]|\n(?! *\n))+)(?:\n *)+\n/),parse:p,react:function(t,e,n){return a("div",n.key,{className:"paragraph",children:e(t.content,n)})},html:function(t,e,n){return i("div",e(t.content,n),{class:"paragraph"})}},escape:{order:J++,match:e(/^\\([^0-9A-Za-z\s])/),parse:function(t,e,n){return{type:"text",content:t[1]}},react:null,html:null},tableSeparator:{order:J++,match:function(t,e){return e.inTable?/^ *\| */.exec(t):null},parse:function(){return{type:"tableSeparator"}},react:function(){return" | "},html:function(){return" | "}},autolink:{order:J++,match:e(/^<([^: >]+:\/[^ >]+)>/),parse:function(t,e,n){return{type:"link",content:[{type:"text",content:t[1]}],target:t[1]}},react:null,html:null},mailto:{order:J++,match:e(/^<([^ >]+@[^ >]+)>/),parse:function(t,e,n){var r=t[1],o=t[1];return Q.test(o)||(o="mailto:"+o),{type:"link",content:[{type:"text",content:r}],target:o}},react:null,html:null},url:{order:J++,match:e(/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/),parse:function(t,e,n){return{type:"link",content:[{type:"text",content:t[1]}],target:t[1],title:void 0}},react:null,html:null},link:{order:J++,match:e(new RegExp("^\\[("+M+")\\]\\("+D+"\\)")),parse:function(t,e,n){return{content:e(t[1],n),target:l(t[2]),title:t[3]}},react:function(t,e,n){return a("a",n.key,{href:u(t.target),title:t.title,children:e(t.content,n)})},html:function(t,e,n){var r={href:u(t.target),title:t.title};return i("a",e(t.content,n),r)}},image:{order:J++,match:e(new RegExp("^!\\[("+M+")\\]\\("+D+"\\)")),parse:function(t,e,n){return{alt:t[1],target:l(t[2]),title:t[3]}},react:function(t,e,n){return a("img",n.key,{src:u(t.target),alt:t.alt,title:t.title})},html:function(t,e,n){return i("img","",{src:u(t.target),alt:t.alt,title:t.title},!1)}},reflink:{order:J++,match:e(new RegExp("^\\[("+M+")\\]\\s*\\[([^\\]]*)\\]")),parse:function(t,e,n){return G(t,n,{type:"link",content:e(t[1],n)})},react:null,html:null},refimage:{order:J++,match:e(new RegExp("^!\\[("+M+")\\]\\s*\\[([^\\]]*)\\]")),parse:function(t,e,n){return G(t,n,{type:"image",alt:t[1]})},react:null,html:null},em:{order:J,match:e(new RegExp("^\\b_((?:__|\\\\[\\s\\S]|[^\\\\_])+?)_\\b|^\\*(?=\\S)((?:\\*\\*|\\\\[\\s\\S]|\\s+(?:\\\\[\\s\\S]|[^\\s\\*\\\\]|\\*\\*)|[^\\s\\*\\\\])+?)\\*(?!\\*)")),quality:function(t){return t[0].length+.2},parse:function(t,e,n){return{content:e(t[2]||t[1],n)}},react:function(t,e,n){return a("em",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("em",e(t.content,n))}},strong:{order:J,match:e(/^\*\*((?:\\[\s\S]|[^\\])+?)\*\*(?!\*)/),quality:function(t){return t[0].length+.1},parse:p,react:function(t,e,n){return a("strong",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("strong",e(t.content,n))}},u:{order:J++,match:e(/^__((?:\\[\s\S]|[^\\])+?)__(?!_)/),quality:function(t){return t[0].length},parse:p,react:function(t,e,n){return a("u",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("u",e(t.content,n))}},del:{order:J++,match:e(/^~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s~]|\s(?!~~))+?)~~/),parse:p,react:function(t,e,n){return a("del",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("del",e(t.content,n))}},inlineCode:{order:J++,match:e(/^(`+)([\s\S]*?[^`])\1(?!`)/),parse:function(t,e,n){return{content:t[2].replace(C,"$1")}},react:function(t,e,n){return a("code",n.key,{children:t.content})},html:function(t,e,n){return i("code",d(t.content))}},br:{order:J++,match:o(/^ {2,}\n/),parse:s,react:function(t,e,n){return a("br",n.key,_)},html:function(t,e,n){return"
"}},text:{order:J++,match:o(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]|\n\n| {2,}\n|\w+:\S|$)/),parse:function(t,e,n){return{content:t[0]}},react:function(t,e,n){return t.content},html:function(t,e,n){return d(t.content)}}},V=t(K),W=X(K,"react"),Y=X(K,"html");return{defaultRules:K,parserFor:t,outputFor:X,inlineRegex:e,blockRegex:n,anyScopeRegex:o,parseInline:f,parseBlock:function(t,e,n){var r=n.inline||!1;n.inline=!1;var o=t(e+"\n\n",n);return n.inline=r,o},markdownToReact:H,markdownToHtml:function(t,e){return Y(Z(t,e),e)},ReactMarkdown:function(t){var e={};for(var n in t)"source"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.children=H(t.source),a("div",null,e)},defaultBlockParse:Z,defaultInlineParse:function(t,e){return(e=e||{}).inline=!0,V(t,e)},defaultImplicitParse:U,defaultReactOutput:W,defaultHtmlOutput:Y,preprocess:r,sanitizeText:d,sanitizeUrl:u,unescapeUrl:l,htmlTag:i,reactElement:a,defaultRawParse:V,ruleOutput:function(r,o){return o||"undefined"==typeof console||console.warn("simple-markdown ruleOutput should take 'react' or 'html' as the second argument."),function(t,e,n){return r[t.type][o](t,e,n)}},reactFor:function(l){var c=function(t,e){if(e=e||{},Array.isArray(t)){for(var n=e.key,r=[],o=null,u=0;u";return r?l+e+"":l}function u(t){if(null==t)return null;try{var e=decodeURIComponent(t).replace(/[^A-Za-z0-9/:]/g,"").toLowerCase();if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}catch(t){return null}return t}function l(t){return t.replace(A,"$1")}function f(t,e,n){var r=n.inline||!1;n.inline=!0;var o=t(e,n);return n.inline=r,o}function p(t,e,n){return{content:f(e,t[1],n)}}function s(){return{}}function d(t){return String(t).replace(E,function(t){return S[t]})}var h,m,y,g,v,k=/\r\n?/g,w=/\t/g,x=/\f/g,b="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,_={},E=/[<>&"']/g,S={"<":"<",">":">","&":"&",'"':""","'":"'","/":"/","`":"`"},A=/\\([^0-9A-Za-z\s])/g,R="(?:[*+-]|\\d+\\.)",$="( *)("+R+") +",O=new RegExp("^"+$),T=new RegExp($+"[^\\n]*(?:\\n(?!\\1"+R+" )[^\\n]*)*(\n|$)","gm"),j=/\n{2,}$/,C=/^ (?= *`)|(` *) $/g,P=j,q=/ *\n+$/,F=new RegExp("^( *)("+R+") [\\s\\S]+?(?:\n{2,}(?! )(?!\\1"+R+" )\\n*|\\s*\n*$)"),B=/(?:^|\n)( *)$/,N=(h=/^ *\| *| *\| *$/g,m=/ *$/,y=/^ *-+: *$/,g=/^ *:-+: *$/,v=/^ *:-+ *$/,{parseTable:z(!0),parseNpTable:z(!1),TABLE_REGEX:/^ *(\|.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/,NPTABLE_REGEX:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/});function I(t){return y.test(t)?"right":g.test(t)?"center":v.test(t)?"left":null}function L(t,e,n,r){var o=n.inTable;n.inTable=!0;var u=e(t.trim(),n);n.inTable=o;var a=[[]];return u.forEach(function(t,e){"tableSeparator"===t.type?r&&(0===e||e===u.length-1)||a.push([]):("text"!==t.type||null!=u[e+1]&&"tableSeparator"!==u[e+1].type||(t.content=t.content.replace(m,"")),a[a.length-1].push(t))}),a}function z(p){return function(t,e,n){n.inline=!0;var r,o,u,a,l,c=L(t[1],e,n,p),i=(l=t[2],p&&(l=l.replace(h,"")),l.trim().split("|").map(I)),f=(r=t[3],o=e,u=n,a=p,r.trim().split("\n").map(function(t){return L(t,o,u,a)}));return n.inline=!1,{type:"table",header:c,align:i,cells:f}}}function G(t,e,n){var r=(t[2]||t[1]).replace(/\s+/g," ").toLowerCase();if(e._defs&&e._defs[r]){var o=e._defs[r];n.target=o.target,n.title=o.title}return e._refs=e._refs||{},e._refs[r]=e._refs[r]||[],e._refs[r].push(n),n}function X(n,r,o){if(!r)throw new Error("simple-markdown: outputFor: `property` must be defined. if you just upgraded, you probably need to replace `outputFor` with `reactFor`");var u,t=(n.Array||K.Array)[r];if(!t)throw new Error("simple-markdown: outputFor: to join nodes of type `"+r+"` you must provide an `Array:` joiner rule with that type, Please see the docs for details on specifying an Array rule.");var a=t,l=function(t,e){return u=e=e||u,Array.isArray(t)?a(t,l,e):n[t.type][r](t,l,e)};return function(t,e){return u=c(e,o),l(t,u)}}function Z(t,e){return(e=e||{}).inline=!1,V(t,e)}function U(t,e){var n=j.test(t);return(e=e||{}).inline=!n,V(t,e)}function H(t,e){return W(Z(t,e),e)}var M="(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*",D="\\s*?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*",Q=/mailto:/i,J=0,K={Array:{react:function(t,e,n){for(var r=n.key,o=[],u=0;u"}},codeBlock:{order:J++,match:n(/^(?: [^\n]+\n*)+(?:\n *)+\n/),parse:function(t,e,n){return{lang:void 0,content:t[0].replace(/^ /gm,"").replace(/\n+$/,"")}},react:function(t,e,n){var r=t.lang?"markdown-code-"+t.lang:void 0;return a("pre",n.key,{children:a("code",null,{className:r,children:t.content})})},html:function(t,e,n){var r=t.lang?"markdown-code-"+t.lang:void 0,o=i("code",d(t.content),{class:r});return i("pre",o)}},fence:{order:J++,match:n(/^ *(`{3,}|~{3,}) *(?:(\S+) *)?\n([\s\S]+?)\n?\1 *(?:\n *)+\n/),parse:function(t,e,n){return{type:"codeBlock",lang:t[2]||void 0,content:t[3]}},react:null,html:null},blockQuote:{order:J++,match:n(/^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/),parse:function(t,e,n){return{content:e(t[0].replace(/^ *> ?/gm,""),n)}},react:function(t,e,n){return a("blockquote",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("blockquote",e(t.content,n))}},list:{order:J++,match:function(t,e){var n=null==e.prevCapture?"":e.prevCapture[0],r=B.exec(n),o=e._list||!e.inline;return r&&o?(t=r[1]+t,F.exec(t)):null},parse:function(t,s,d){var e=t[2],n=1]*)>?(?: +["(]([^\n]+)[")])? *\n(?: *\n)*/),parse:function(t,e,n){var r=t[1].replace(/\s+/g," ").toLowerCase(),o=t[2],u=t[3];return n._refs&&n._refs[r]&&n._refs[r].forEach(function(t){t.target=o,t.title=u}),n._defs=n._defs||{},n._defs[r]={target:o,title:u},{def:r,target:o,title:u}},react:function(){return null},html:function(){return""}},table:{order:J++,match:n(N.TABLE_REGEX),parse:N.parseTable,react:function(e,n,r){function o(t){return null==e.align[t]?{}:{textAlign:e.align[t]}}var t=e.header.map(function(t,e){return a("th",""+e,{style:o(e),scope:"col",children:n(t,r)})}),u=e.cells.map(function(t,e){return a("tr",""+e,{children:t.map(function(t,e){return a("td",""+e,{style:o(e),children:n(t,r)})})})});return a("table",r.key,{children:[a("thead","thead",{children:a("tr",null,{children:t})}),a("tbody","tbody",{children:u})]})},html:function(e,n,r){function o(t){return null==e.align[t]?"":"text-align:"+e.align[t]+";"}var t=e.header.map(function(t,e){return i("th",n(t,r),{style:o(e),scope:"col"})}).join(""),u=e.cells.map(function(t){var e=t.map(function(t,e){return i("td",n(t,r),{style:o(e)})}).join("");return i("tr",e)}).join(""),a=i("thead",i("tr",t)),l=i("tbody",u);return i("table",a+l)}},newline:{order:J++,match:n(/^(?:\n *)*\n/),parse:s,react:function(t,e,n){return"\n"},html:function(t,e,n){return"\n"}},paragraph:{order:J++,match:n(/^((?:[^\n]|\n(?! *\n))+)(?:\n *)+\n/),parse:p,react:function(t,e,n){return a("div",n.key,{className:"paragraph",children:e(t.content,n)})},html:function(t,e,n){return i("div",e(t.content,n),{class:"paragraph"})}},escape:{order:J++,match:e(/^\\([^0-9A-Za-z\s])/),parse:function(t,e,n){return{type:"text",content:t[1]}},react:null,html:null},tableSeparator:{order:J++,match:function(t,e){return e.inTable?/^ *\| */.exec(t):null},parse:function(){return{type:"tableSeparator"}},react:function(){return" | "},html:function(){return" | "}},autolink:{order:J++,match:e(/^<([^: >]+:\/[^ >]+)>/),parse:function(t,e,n){return{type:"link",content:[{type:"text",content:t[1]}],target:t[1]}},react:null,html:null},mailto:{order:J++,match:e(/^<([^ >]+@[^ >]+)>/),parse:function(t,e,n){var r=t[1],o=t[1];return Q.test(o)||(o="mailto:"+o),{type:"link",content:[{type:"text",content:r}],target:o}},react:null,html:null},url:{order:J++,match:e(/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/),parse:function(t,e,n){return{type:"link",content:[{type:"text",content:t[1]}],target:t[1],title:void 0}},react:null,html:null},link:{order:J++,match:e(new RegExp("^\\[("+M+")\\]\\("+D+"\\)")),parse:function(t,e,n){return{content:e(t[1],n),target:l(t[2]),title:t[3]}},react:function(t,e,n){return a("a",n.key,{href:u(t.target),title:t.title,children:e(t.content,n)})},html:function(t,e,n){var r={href:u(t.target),title:t.title};return i("a",e(t.content,n),r)}},image:{order:J++,match:e(new RegExp("^!\\[("+M+")\\]\\("+D+"\\)")),parse:function(t,e,n){return{alt:t[1],target:l(t[2]),title:t[3]}},react:function(t,e,n){return a("img",n.key,{src:u(t.target),alt:t.alt,title:t.title})},html:function(t,e,n){return i("img","",{src:u(t.target),alt:t.alt,title:t.title},!1)}},reflink:{order:J++,match:e(new RegExp("^\\[("+M+")\\]\\s*\\[([^\\]]*)\\]")),parse:function(t,e,n){return G(t,n,{type:"link",content:e(t[1],n)})},react:null,html:null},refimage:{order:J++,match:e(new RegExp("^!\\[("+M+")\\]\\s*\\[([^\\]]*)\\]")),parse:function(t,e,n){return G(t,n,{type:"image",alt:t[1]})},react:null,html:null},em:{order:J,match:e(new RegExp("^\\b_((?:__|\\\\[\\s\\S]|[^\\\\_])+?)_\\b|^\\*(?=\\S)((?:\\*\\*|\\\\[\\s\\S]|\\s+(?:\\\\[\\s\\S]|[^\\s\\*\\\\]|\\*\\*)|[^\\s\\*\\\\])+?)\\*(?!\\*)")),quality:function(t){return t[0].length+.2},parse:function(t,e,n){return{content:e(t[2]||t[1],n)}},react:function(t,e,n){return a("em",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("em",e(t.content,n))}},strong:{order:J,match:e(/^\*\*((?:\\[\s\S]|[^\\])+?)\*\*(?!\*)/),quality:function(t){return t[0].length+.1},parse:p,react:function(t,e,n){return a("strong",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("strong",e(t.content,n))}},u:{order:J++,match:e(/^__((?:\\[\s\S]|[^\\])+?)__(?!_)/),quality:function(t){return t[0].length},parse:p,react:function(t,e,n){return a("u",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("u",e(t.content,n))}},del:{order:J++,match:e(/^~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s~\\]|\s(?!~~))+?)~~/),parse:p,react:function(t,e,n){return a("del",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("del",e(t.content,n))}},inlineCode:{order:J++,match:e(/^(`+)([\s\S]*?[^`])\1(?!`)/),parse:function(t,e,n){return{content:t[2].replace(C,"$1")}},react:function(t,e,n){return a("code",n.key,{children:t.content})},html:function(t,e,n){return i("code",d(t.content))}},br:{order:J++,match:o(/^ {2,}\n/),parse:s,react:function(t,e,n){return a("br",n.key,_)},html:function(t,e,n){return"
"}},text:{order:J++,match:o(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]|\n\n| {2,}\n|\w+:\S|$)/),parse:function(t,e,n){return{content:t[0]}},react:function(t,e,n){return t.content},html:function(t,e,n){return d(t.content)}}},V=t(K),W=X(K,"react"),Y=X(K,"html");return{defaultRules:K,parserFor:t,outputFor:X,inlineRegex:e,blockRegex:n,anyScopeRegex:o,parseInline:f,parseBlock:function(t,e,n){var r=n.inline||!1;n.inline=!1;var o=t(e+"\n\n",n);return n.inline=r,o},markdownToReact:H,markdownToHtml:function(t,e){return Y(Z(t,e),e)},ReactMarkdown:function(t){var e={};for(var n in t)"source"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.children=H(t.source),a("div",null,e)},defaultBlockParse:Z,defaultInlineParse:function(t,e){return(e=e||{}).inline=!0,V(t,e)},defaultImplicitParse:U,defaultReactOutput:W,defaultHtmlOutput:Y,preprocess:r,sanitizeText:d,sanitizeUrl:u,unescapeUrl:l,htmlTag:i,reactElement:a,defaultRawParse:V,ruleOutput:function(r,o){return o||"undefined"==typeof console||console.warn("simple-markdown ruleOutput should take 'react' or 'html' as the second argument."),function(t,e,n){return r[t.type][o](t,e,n)}},reactFor:function(l){var c=function(t,e){if(e=e||{},Array.isArray(t)){for(var n=e.key,r=[],o=null,u=0;u