diff --git a/CHANGES.md b/CHANGES.md index 5363f68b3d..e6e1f1f4a9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,6 +22,9 @@ New Languages: Language Improvements: +- fix(r) fixed keywords not properly spaced (#2852) [Josh Goebel][] +- fix(javascript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] +- fix(livescript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] - bug(xml) XML grammar was far too imprecise/fuzzy [Josh Goebel][] - enh(xml) Improve precision to prevent false auto-detect positives [Josh Goebel][] - fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) [Josh Goebel][] diff --git a/src/languages/1c.js b/src/languages/1c.js index d40f539ec5..595aaeca58 100644 --- a/src/languages/1c.js +++ b/src/languages/1c.js @@ -515,5 +515,5 @@ export default function(hljs) { STRINGS, DATE ] - } + }; } diff --git a/src/languages/hy.js b/src/languages/hy.js index b86d6f787f..fe913e10df 100644 --- a/src/languages/hy.js +++ b/src/languages/hy.js @@ -101,5 +101,5 @@ export default function(hljs) { aliases: ['hylang'], illegal: /\S/, contains: [hljs.SHEBANG(), LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL] - } + }; } diff --git a/src/languages/java.js b/src/languages/java.js index 9c949f726c..1e9ab182dc 100644 --- a/src/languages/java.js +++ b/src/languages/java.js @@ -5,8 +5,6 @@ Category: common, enterprise Website: https://www.java.com/ */ -import * as regex from '../lib/regex.js'; - export default function(hljs) { var JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*'; var GENERIC_IDENT_RE = JAVA_IDENT_RE + '(<' + JAVA_IDENT_RE + '(\\s*,\\s*' + JAVA_IDENT_RE + ')*>)?'; diff --git a/src/languages/javascript.js b/src/languages/javascript.js index bb077d6138..2bccc2190c 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -18,7 +18,7 @@ export default function(hljs) { * @param {{after:number}} param1 */ const hasClosingTag = (match, { after }) => { - const tag = match[0].replace("<", ""); + const tag = "" + match[0].slice(1); const pos = match.input.indexOf(tag, after); return pos !== -1; }; @@ -256,9 +256,7 @@ export default function(hljs) { regex.lookahead(regex.concat( // we also need to allow for multiple possible comments inbetween // the first key:value pairing - /(\/\/.*$)*/, - /(\/\*(.|\n)*\*\/)*/, - /\s*/, + /(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/, IDENT_RE + '\\s*:'))), relevance: 0, contains: [ diff --git a/src/languages/kotlin.js b/src/languages/kotlin.js index e2610a9412..6de5532d04 100644 --- a/src/languages/kotlin.js +++ b/src/languages/kotlin.js @@ -66,7 +66,7 @@ export default function(hljs) { } ] }; - SUBST.contains.push(STRING) + SUBST.contains.push(STRING); var ANNOTATION_USE_SITE = { className: 'meta', begin: '@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*' + hljs.UNDERSCORE_IDENT_RE + ')?' diff --git a/src/languages/livescript.js b/src/languages/livescript.js index c8e9f81301..6d5f4abf15 100644 --- a/src/languages/livescript.js +++ b/src/languages/livescript.js @@ -115,7 +115,7 @@ export default function(hljs) { { // regex can't start with space to parse x / 2 / 3 as two divisions // regex can't start with *, and it supports an "illegal" in the main mode - begin: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W)/ + begin: /\/(?![ *])(\\.|[^\\\n])*?\/[gim]*(?=\W)/ } ] }, diff --git a/src/languages/mercury.js b/src/languages/mercury.js index eeab89f5e6..ece8023bd4 100644 --- a/src/languages/mercury.js +++ b/src/languages/mercury.js @@ -49,7 +49,7 @@ export default function(hljs) { begin: '\\\\[abfnrtv]\\|\\\\x[0-9a-fA-F]*\\\\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]', relevance: 0 }; - STRING.contains = STRING.contains.slice() // we need our own copy of contains + STRING.contains = STRING.contains.slice(); // we need our own copy of contains STRING.contains.push(STRING_FMT); var IMPLICATION = { diff --git a/src/languages/parser3.js b/src/languages/parser3.js index 18ee3634ae..e300fc4109 100644 --- a/src/languages/parser3.js +++ b/src/languages/parser3.js @@ -20,7 +20,7 @@ export default function(hljs) { contains: [ hljs.COMMENT('^#', '$'), hljs.COMMENT( - /\\^rem\{/, + /\^rem\{/, /\}/, { relevance: 10, diff --git a/src/languages/powershell.js b/src/languages/powershell.js index 5e80f4714d..98523c0d82 100644 --- a/src/languages/powershell.js +++ b/src/languages/powershell.js @@ -242,7 +242,7 @@ export default function(hljs) { ) }; - PS_METHODS.contains.unshift(PS_TYPE) + PS_METHODS.contains.unshift(PS_TYPE); return { name: 'PowerShell', diff --git a/src/languages/r.js b/src/languages/r.js index b095333004..82a9874882 100644 --- a/src/languages/r.js +++ b/src/languages/r.js @@ -32,22 +32,22 @@ export default function(hljs) { // Primitive functions // These are all the functions in `base` that are implemented as a // `.Primitive`, minus those functions that are also keywords. - 'abs acos acosh all any anyNA Arg as.call as.character' + - 'as.complex as.double as.environment as.integer as.logical' + - 'as.null.default as.numeric as.raw asin asinh atan atanh attr' + - 'attributes baseenv browser c call ceiling class Conj cos cosh' + - 'cospi cummax cummin cumprod cumsum digamma dim dimnames' + - 'emptyenv exp expression floor forceAndCall gamma gc.time' + - 'globalenv Im interactive invisible is.array is.atomic is.call' + - 'is.character is.complex is.double is.environment is.expression' + - 'is.finite is.function is.infinite is.integer is.language' + - 'is.list is.logical is.matrix is.na is.name is.nan is.null' + - 'is.numeric is.object is.pairlist is.raw is.recursive is.single' + - 'is.symbol lazyLoadDBfetch length lgamma list log max min' + - 'missing Mod names nargs nzchar oldClass on.exit pos.to.env' + - 'proc.time prod quote range Re rep retracemem return round' + - 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt' + - 'standardGeneric substitute sum switch tan tanh tanpi tracemem' + + 'abs acos acosh all any anyNA Arg as.call as.character ' + + 'as.complex as.double as.environment as.integer as.logical ' + + 'as.null.default as.numeric as.raw asin asinh atan atanh attr ' + + 'attributes baseenv browser c call ceiling class Conj cos cosh ' + + 'cospi cummax cummin cumprod cumsum digamma dim dimnames ' + + 'emptyenv exp expression floor forceAndCall gamma gc.time ' + + 'globalenv Im interactive invisible is.array is.atomic is.call ' + + 'is.character is.complex is.double is.environment is.expression ' + + 'is.finite is.function is.infinite is.integer is.language ' + + 'is.list is.logical is.matrix is.na is.name is.nan is.null ' + + 'is.numeric is.object is.pairlist is.raw is.recursive is.single ' + + 'is.symbol lazyLoadDBfetch length lgamma list log max min ' + + 'missing Mod names nargs nzchar oldClass on.exit pos.to.env ' + + 'proc.time prod quote range Re rep retracemem return round ' + + 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt ' + + 'standardGeneric substitute sum switch tan tanh tanpi tracemem ' + 'trigamma trunc unclass untracemem UseMethod xtfrm', }, diff --git a/src/languages/swift.js b/src/languages/swift.js index 7034f24f45..ad38d8777f 100644 --- a/src/languages/swift.js +++ b/src/languages/swift.js @@ -50,7 +50,7 @@ export default function(hljs) { var OPTIONAL_USING_TYPE = { className: 'type', begin: '\\b[A-Z][\\w\u00C0-\u02B8\']*[!?]' - } + }; var BLOCK_COMMENT = hljs.COMMENT( '/\\*', '\\*/', diff --git a/tools/developer.html b/tools/developer.html index 3ef72618a5..6a53a8abfd 100644 --- a/tools/developer.html +++ b/tools/developer.html @@ -57,7 +57,7 @@ } -
+