Adjusting grammar to match \c escape "correctly"
\c followed by something other than a-z leads to inconsistent behavior across browsers. Most will treat it as a series of literals (/\c#/ will match the string "\\c#" for example)
This commit is contained in:
parent
101b457260
commit
580af045d6
@ -22,20 +22,20 @@ grammar JavascriptRegexp
|
|||||||
/ charset_literal <Literal>
|
/ charset_literal <Literal>
|
||||||
charset_escape <- "\\" esc:(
|
charset_escape <- "\\" esc:(
|
||||||
code:[bdDfnrsStvwW] arg:""?
|
code:[bdDfnrsStvwW] arg:""?
|
||||||
/ code:"c" arg:.
|
/ code:"c" arg:[a-zA-Z]
|
||||||
/ code:"0" arg:[0-7]+
|
/ code:"0" arg:[0-7]+
|
||||||
/ code:"x" arg:( [0-9a-fA-F] [0-9a-fA-F] )
|
/ code:"x" arg:( [0-9a-fA-F] [0-9a-fA-F] )
|
||||||
/ code:"u" arg:( [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] )
|
/ code:"u" arg:( [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] )
|
||||||
/ code:"0" arg:""? )
|
/ code:"0" arg:""? )
|
||||||
charset_literal <- ( ""? literal:[^\\\]] ) / ( "\\" literal:. )
|
charset_literal <- ( ""? literal:[^\\\]] ) / ( literal:"\\" &"c" ) / ( "\\" literal:. )
|
||||||
terminal <- "." <AnyCharacter>
|
terminal <- "." <AnyCharacter>
|
||||||
/ escape <Escape>
|
/ escape <Escape>
|
||||||
/ literal <Literal>
|
/ literal <Literal>
|
||||||
escape <- "\\" esc:(
|
escape <- "\\" esc:(
|
||||||
code:[bBdDfnrsStvwW1-9] arg:""?
|
code:[bBdDfnrsStvwW1-9] arg:""?
|
||||||
/ code:"c" arg:.
|
/ code:"c" arg:[a-zA-Z]
|
||||||
/ code:"0" arg:[0-7]+
|
/ code:"0" arg:[0-7]+
|
||||||
/ code:"x" arg:( [0-9a-fA-F] [0-9a-fA-F] )
|
/ code:"x" arg:( [0-9a-fA-F] [0-9a-fA-F] )
|
||||||
/ code:"u" arg:( [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] )
|
/ code:"u" arg:( [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] )
|
||||||
/ code:"0" arg:""? )
|
/ code:"0" arg:""? )
|
||||||
literal <- ( ""? literal:[^|\\/.\[\(\)?+*$^] ) / ( "\\" literal:. )
|
literal <- ( ""? literal:[^|\\/.\[\(\)?+*$^] ) / ( literal:"\\" &"c" ) / ( "\\" literal:. )
|
||||||
|
Loading…
Reference in New Issue
Block a user