From 24a00151488c9c9b8e4f39615f0eaa349aa7fb44 Mon Sep 17 00:00:00 2001 From: satyr Date: Sun, 10 Oct 2010 07:32:49 +0900 Subject: [PATCH] lexer: made REGEX more accurate --- lib/lexer.js | 2 +- src/lexer.coffee | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 0d5d3acb..44ad6188 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -605,7 +605,7 @@ MULTI_DENT = /^(?:\n[ \t]*)+/; SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/; JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/; - REGEX = /^\/(?!\s)(?:[^[\/\n\\]+|\\.|\[([^\\\]]+|\\.)*])+\/[imgy]{0,4}(?![A-Za-z])/; + REGEX = /^\/(?!\s)(?:[^[\/\n\\]+|\\[\s\S]|\[([^\]\n\\]+|\\[\s\S])*])+\/[imgy]{0,4}(?![A-Za-z])/; HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?![A-Za-z])/; HEREGEX_OMIT = /\s+(?:#.*)?/g; MULTILINER = /\n/g; diff --git a/src/lexer.coffee b/src/lexer.coffee index f7d58afd..a252f76f 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -557,10 +557,10 @@ JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/ # Regex-matching-regexes. REGEX = /// ^ - / (?!\s) # disallow leading whitespace - (?: [^ [ / \n \\ ]+ # every other thing - | \\. # anything escaped - | \[ ( [^\\\]]+ | \\. )* ] # character class + / (?!\s) # disallow leading whitespace + (?: [^ [ / \n \\ ]+ # every other thing + | \\[\s\S] # anything escaped + | \[ ( [^ \] \n \\ ]+ | \\[\s\S] )* ] # character class )+ / [imgy]{0,4} (?![A-Za-z]) ///