From 57f7fae6846eb64ccc9fce1f5e1afa07a2c2733f Mon Sep 17 00:00:00 2001 From: David Majda Date: Thu, 8 May 2014 15:26:36 +0200 Subject: [PATCH] Fix a bug in |stringEscape| The |stringEscape| function both in lib/compiler/javascript.js and in generated parsers didn't escape characters in the U+0100..U+107F and U+1000..U+107F ranges. --- lib/compiler/javascript.js | 4 ++-- lib/compiler/passes/generate-javascript.js | 4 ++-- lib/parser.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/compiler/javascript.js b/lib/compiler/javascript.js index 07948ae..a4ee07c 100644 --- a/lib/compiler/javascript.js +++ b/lib/compiler/javascript.js @@ -23,8 +23,8 @@ var javascript = { .replace(/\r/g, '\\r') // carriage return .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) - .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) - .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); + .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) + .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); }, regexpClassEscape: function(s) { diff --git a/lib/compiler/passes/generate-javascript.js b/lib/compiler/passes/generate-javascript.js index 6e0f894..8806414 100644 --- a/lib/compiler/passes/generate-javascript.js +++ b/lib/compiler/passes/generate-javascript.js @@ -893,8 +893,8 @@ function generateJavaScript(ast, options) { ' .replace(/\\r/g, \'\\\\r\')', // carriage return ' .replace(/[\\x00-\\x07\\x0B\\x0E\\x0F]/g, function(ch) { return \'\\\\x0\' + hex(ch); })', ' .replace(/[\\x10-\\x1F\\x80-\\xFF]/g, function(ch) { return \'\\\\x\' + hex(ch); })', - ' .replace(/[\\u0180-\\u0FFF]/g, function(ch) { return \'\\\\u0\' + hex(ch); })', - ' .replace(/[\\u1080-\\uFFFF]/g, function(ch) { return \'\\\\u\' + hex(ch); });', + ' .replace(/[\\u0100-\\u0FFF]/g, function(ch) { return \'\\\\u0\' + hex(ch); })', + ' .replace(/[\\u1000-\\uFFFF]/g, function(ch) { return \'\\\\u\' + hex(ch); });', ' }', '', ' var expectedDescs = new Array(expected.length),', diff --git a/lib/parser.js b/lib/parser.js index 72dfcfe..3a96ca4 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -465,8 +465,8 @@ module.exports = (function() { .replace(/\r/g, '\\r') .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) - .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) - .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); + .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) + .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); } var expectedDescs = new Array(expected.length),