diff --git a/.eslintrc.js b/.eslintrc.js index 5002ad9c32..0d98692033 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -56,17 +56,18 @@ module.exports = { 'jsdoc/require-property-name': 'warn', // regexp - 'regexp/no-empty-capturing-group': 'error', 'regexp/no-dupe-disjunctions': 'error', 'regexp/no-empty-alternative': 'error', + 'regexp/no-empty-capturing-group': 'error', 'regexp/no-empty-lookarounds-assertion': 'error', 'regexp/no-lazy-ends': 'error', 'regexp/no-obscure-range': 'error', 'regexp/no-optional-assertion': 'error', 'regexp/no-standalone-backslash': 'error', + 'regexp/no-super-linear-backtracking': 'error', + 'regexp/no-unused-capturing-group': 'error', 'regexp/no-zero-quantifier': 'error', 'regexp/optimal-lookaround-quantifier': 'error', - 'regexp/no-unused-capturing-group': 'error', 'regexp/match-any': 'warn', 'regexp/negation': 'warn', diff --git a/components/prism-core.js b/components/prism-core.js index 776c292164..cf77da513b 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -201,7 +201,7 @@ var Prism = (function (_self) { // at _.util.currentScript (http://localhost/components/prism-core.js:119:5) // at Global code (http://localhost/components/prism-core.js:606:1) - var src = (/at [^(\r\n]*\((.*):.+:.+\)$/i.exec(err.stack) || [])[1]; + var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1]; if (src) { var scripts = document.getElementsByTagName('script'); for (var i in scripts) { diff --git a/components/prism-core.min.js b/components/prism-core.min.js index e1a5842c3a..4ff2c0fc71 100644 --- a/components/prism-core.min.js +++ b/components/prism-core.min.js @@ -1 +1 @@ -var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(u){var c=/\blang(?:uage)?-([\w-]+)\b/i,n=0,e={},M={manual:u.Prism&&u.Prism.manual,disableWorkerMessageHandler:u.Prism&&u.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof W?new W(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/=l.reach);y+=m.value.length,m=m.next){var b=m.value;if(t.length>n.length)return;if(!(b instanceof W)){var k,x=1;if(h){if(!(k=z(v,y,n,f)))break;var w=k.index,A=k.index+k[0].length,P=y;for(P+=m.value.length;P<=w;)m=m.next,P+=m.value.length;if(P-=m.value.length,y=P,m.value instanceof W)continue;for(var E=m;E!==t.tail&&(Pl.reach&&(l.reach=N);var j=m.prev;O&&(j=I(t,j,O),y+=O.length),q(t,j,x);var C=new W(o,g?M.tokenize(S,g):S,d,S);if(m=I(t,j,C),L&&I(t,m,L),1l.reach&&(l.reach=_.reach)}}}}}}(e,a,n,a.head,0),function(e){var n=[],t=e.head.next;for(;t!==e.tail;)n.push(t.value),t=t.next;return n}(a)},hooks:{all:{},add:function(e,n){var t=M.hooks.all;t[e]=t[e]||[],t[e].push(n)},run:function(e,n){var t=M.hooks.all[e];if(t&&t.length)for(var r,a=0;r=t[a++];)r(n)}},Token:W};function W(e,n,t,r){this.type=e,this.content=n,this.alias=t,this.length=0|(r||"").length}function z(e,n,t,r){e.lastIndex=n;var a=e.exec(t);if(a&&r&&a[1]){var i=a[1].length;a.index+=i,a[0]=a[0].slice(i)}return a}function i(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function I(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function q(e,n,t){for(var r=n.next,a=0;a"+a.content+""},!u.document)return u.addEventListener&&(M.disableWorkerMessageHandler||u.addEventListener("message",function(e){var n=JSON.parse(e.data),t=n.language,r=n.code,a=n.immediateClose;u.postMessage(M.highlight(r,M.languages[t],t)),a&&u.close()},!1)),M;var t=M.util.currentScript();function r(){M.manual||M.highlightAll()}if(t&&(M.filename=t.src,t.hasAttribute("data-manual")&&(M.manual=!0)),!M.manual){var a=document.readyState;"loading"===a||"interactive"===a&&t&&t.defer?document.addEventListener("DOMContentLoaded",r):window.requestAnimationFrame?window.requestAnimationFrame(r):window.setTimeout(r,16)}return M}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); \ No newline at end of file +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(u){var c=/\blang(?:uage)?-([\w-]+)\b/i,n=0,e={},M={manual:u.Prism&&u.Prism.manual,disableWorkerMessageHandler:u.Prism&&u.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof W?new W(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/=l.reach);y+=m.value.length,m=m.next){var b=m.value;if(t.length>n.length)return;if(!(b instanceof W)){var k,x=1;if(h){if(!(k=z(v,y,n,f)))break;var w=k.index,A=k.index+k[0].length,P=y;for(P+=m.value.length;P<=w;)m=m.next,P+=m.value.length;if(P-=m.value.length,y=P,m.value instanceof W)continue;for(var E=m;E!==t.tail&&(Pl.reach&&(l.reach=N);var j=m.prev;O&&(j=I(t,j,O),y+=O.length),q(t,j,x);var C=new W(o,g?M.tokenize(S,g):S,d,S);if(m=I(t,j,C),L&&I(t,m,L),1l.reach&&(l.reach=_.reach)}}}}}}(e,a,n,a.head,0),function(e){var n=[],t=e.head.next;for(;t!==e.tail;)n.push(t.value),t=t.next;return n}(a)},hooks:{all:{},add:function(e,n){var t=M.hooks.all;t[e]=t[e]||[],t[e].push(n)},run:function(e,n){var t=M.hooks.all[e];if(t&&t.length)for(var r,a=0;r=t[a++];)r(n)}},Token:W};function W(e,n,t,r){this.type=e,this.content=n,this.alias=t,this.length=0|(r||"").length}function z(e,n,t,r){e.lastIndex=n;var a=e.exec(t);if(a&&r&&a[1]){var i=a[1].length;a.index+=i,a[0]=a[0].slice(i)}return a}function i(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function I(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function q(e,n,t){for(var r=n.next,a=0;a"+a.content+""},!u.document)return u.addEventListener&&(M.disableWorkerMessageHandler||u.addEventListener("message",function(e){var n=JSON.parse(e.data),t=n.language,r=n.code,a=n.immediateClose;u.postMessage(M.highlight(r,M.languages[t],t)),a&&u.close()},!1)),M;var t=M.util.currentScript();function r(){M.manual||M.highlightAll()}if(t&&(M.filename=t.src,t.hasAttribute("data-manual")&&(M.manual=!0)),!M.manual){var a=document.readyState;"loading"===a||"interactive"===a&&t&&t.defer?document.addEventListener("DOMContentLoaded",r):window.requestAnimationFrame?window.requestAnimationFrame(r):window.setTimeout(r,16)}return M}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); \ No newline at end of file diff --git a/components/prism-kumir.js b/components/prism-kumir.js index 565427f79f..679574078b 100644 --- a/components/prism-kumir.js +++ b/components/prism-kumir.js @@ -76,6 +76,7 @@ /** Should be performed after searching for reserved words. */ 'name': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: wrapId(/(^|[])[^\d][^]*(?:\x20+[^]+)*(?=[]|$)/.source), lookbehind: true }, diff --git a/components/prism-textile.js b/components/prism-textile.js index e96e601e6e..26d7ef32bf 100644 --- a/components/prism-textile.js +++ b/components/prism-textile.js @@ -91,6 +91,7 @@ }, 'inline': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^|[^a-zA-Z\d])(\*\*|__|\?\?|[*_%@+\-^~])*.+?\2(?![a-zA-Z\d])/.source), lookbehind: true, inside: { @@ -98,18 +99,21 @@ // *bold*, **bold** 'bold': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^(\*\*?)*).+?(?=\2)/.source), lookbehind: true }, // _italic_, __italic__ 'italic': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^(__?)*).+?(?=\2)/.source), lookbehind: true }, // ??cite?? 'cite': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^\?\?*).+?(?=\?\?)/.source), lookbehind: true, alias: 'string' @@ -117,6 +121,7 @@ // @code@ 'code': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^@*).+?(?=@)/.source), lookbehind: true, alias: 'keyword' @@ -124,18 +129,21 @@ // +inserted+ 'inserted': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^\+*).+?(?=\+)/.source), lookbehind: true }, // -deleted- 'deleted': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^-*).+?(?=-)/.source), lookbehind: true }, // %span% 'span': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^%*).+?(?=%)/.source), lookbehind: true }, @@ -168,9 +176,11 @@ // "text":http://example.com // "text":link-ref 'link': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/"*[^"]+":.+?(?=[^\w/]?(?:\s|$))/.source), inside: { 'text': { + // eslint-disable-next-line regexp/no-super-linear-backtracking pattern: withModifier(/(^"*)[^"]+(?=")/.source), lookbehind: true }, diff --git a/docs/prism-core.js.html b/docs/prism-core.js.html index 8c6e5ee416..6d6654abc3 100644 --- a/docs/prism-core.js.html +++ b/docs/prism-core.js.html @@ -254,7 +254,7 @@

prism-core.js

// at _.util.currentScript (http://localhost/components/prism-core.js:119:5) // at Global code (http://localhost/components/prism-core.js:606:1) - var src = (/at [^(\r\n]*\((.*):.+:.+\)$/i.exec(err.stack) || [])[1]; + var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1]; if (src) { var scripts = document.getElementsByTagName('script'); for (var i in scripts) { diff --git a/gulpfile.js/changelog.js b/gulpfile.js/changelog.js index f4d65e6408..d945d0fd27 100644 --- a/gulpfile.js/changelog.js +++ b/gulpfile.js/changelog.js @@ -58,6 +58,7 @@ function createSortedArray(compareFn) { * @typedef {"A" | "C" | "D" | "M" | "R" | "T" | "U" | "X" | "B"} ChangeMode */ async function getCommitInfo(line) { + // eslint-disable-next-line regexp/no-super-linear-backtracking const [, hash, message] = /^([a-f\d]+)\s+(.*)$/i.exec(line); /* The output looks like this: diff --git a/prism.js b/prism.js index c17bcff46c..2358d68c29 100644 --- a/prism.js +++ b/prism.js @@ -206,7 +206,7 @@ var Prism = (function (_self) { // at _.util.currentScript (http://localhost/components/prism-core.js:119:5) // at Global code (http://localhost/components/prism-core.js:606:1) - var src = (/at [^(\r\n]*\((.*):.+:.+\)$/i.exec(err.stack) || [])[1]; + var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1]; if (src) { var scripts = document.getElementsByTagName('script'); for (var i in scripts) {