@@ -115,10 +115,10 @@ const kArrayType = 1;
115115const kArrayExtrasType = 2 ;
116116
117117/* eslint-disable no-control-regex */
118- const strEscapeSequencesRegExp = / [ \x00 - \x1f \x27 \x5c ] / ;
119- const strEscapeSequencesReplacer = / [ \x00 - \x1f \x27 \x5c ] / g;
120- const strEscapeSequencesRegExpSingle = / [ \x00 - \x1f \x5c ] / ;
121- const strEscapeSequencesReplacerSingle = / [ \x00 - \x1f \x5c ] / g;
118+ const strEscapeSequencesRegExp = / [ \x00 - \x1f \x27 \x5c \x7f - \x9f ] / ;
119+ const strEscapeSequencesReplacer = / [ \x00 - \x1f \x27 \x5c \x7f - \x9f ] / g;
120+ const strEscapeSequencesRegExpSingle = / [ \x00 - \x1f \x5c \x7f - \x9f ] / ;
121+ const strEscapeSequencesReplacerSingle = / [ \x00 - \x1f \x5c \x7f - \x9f ] / g;
122122/* eslint-enable no-control-regex */
123123
124124const keyStrRegExp = / ^ [ a - z A - Z _ ] [ a - z A - Z _ 0 - 9 ] * $ / ;
@@ -134,21 +134,23 @@ const kWeak = 0;
134134const kIterator = 1 ;
135135const kMapEntries = 2 ;
136136
137- // Escaped special characters. Use empty strings to fill up unused entries.
137+ // Escaped control characters (plus the single quote and the backslash). Use
138+ // empty strings to fill up unused entries.
138139const meta = [
139- '\\u0000' , '\\u0001' , '\\u0002' , '\\u0003' , '\\u0004' ,
140- '\\u0005' , '\\u0006' , '\\u0007' , '\\b' , '\\t' ,
141- '\\n' , '\\u000b' , '\\f' , '\\r' , '\\u000e' ,
142- '\\u000f' , '\\u0010' , '\\u0011' , '\\u0012' , '\\u0013' ,
143- '\\u0014' , '\\u0015' , '\\u0016' , '\\u0017' , '\\u0018' ,
144- '\\u0019' , '\\u001a' , '\\u001b' , '\\u001c' , '\\u001d' ,
145- '\\u001e' , '\\u001f' , '' , '' , '' ,
146- '' , '' , '' , '' , "\\'" , '' , '' , '' , '' , '' ,
147- '' , '' , '' , '' , '' , '' , '' , '' , '' , '' ,
148- '' , '' , '' , '' , '' , '' , '' , '' , '' , '' ,
149- '' , '' , '' , '' , '' , '' , '' , '' , '' , '' ,
150- '' , '' , '' , '' , '' , '' , '' , '' , '' , '' ,
151- '' , '' , '' , '' , '' , '' , '' , '\\\\'
140+ '\\x00' , '\\x01' , '\\x02' , '\\x03' , '\\x04' , '\\x05' , '\\x06' , '\\x07' , // x07
141+ '\\b' , '\\t' , '\\n' , '\\x0B' , '\\f' , '\\r' , '\\x0E' , '\\x0F' , // x0F
142+ '\\x10' , '\\x11' , '\\x12' , '\\x13' , '\\x14' , '\\x15' , '\\x16' , '\\x17' , // x17
143+ '\\x18' , '\\x19' , '\\x1A' , '\\x1B' , '\\x1C' , '\\x1D' , '\\x1E' , '\\x1F' , // x1F
144+ '' , '' , '' , '' , '' , '' , '' , "\\'" , '' , '' , '' , '' , '' , '' , '' , '' , // x2F
145+ '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , // x3F
146+ '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , // x4F
147+ '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '\\\\' , '' , '' , '' , // x5F
148+ '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , // x6F
149+ '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '' , '\\x7F' , // x7F
150+ '\\x80' , '\\x81' , '\\x82' , '\\x83' , '\\x84' , '\\x85' , '\\x86' , '\\x87' , // x87
151+ '\\x88' , '\\x89' , '\\x8A' , '\\x8B' , '\\x8C' , '\\x8D' , '\\x8E' , '\\x8F' , // x8F
152+ '\\x90' , '\\x91' , '\\x92' , '\\x93' , '\\x94' , '\\x95' , '\\x96' , '\\x97' , // x97
153+ '\\x98' , '\\x99' , '\\x9A' , '\\x9B' , '\\x9C' , '\\x9D' , '\\x9E' , '\\x9F' , // x9F
152154] ;
153155
154156function getUserOptions ( ctx ) {
@@ -317,7 +319,10 @@ function strEscape(str) {
317319 const lastIndex = str . length ;
318320 for ( let i = 0 ; i < lastIndex ; i ++ ) {
319321 const point = str . charCodeAt ( i ) ;
320- if ( point === singleQuote || point === 92 || point < 32 ) {
322+ if ( point === singleQuote ||
323+ point === 92 ||
324+ point < 32 ||
325+ ( point > 126 && point < 160 ) ) {
321326 if ( last === i ) {
322327 result += meta [ point ] ;
323328 } else {
0 commit comments