aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lj_lex.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lj_lex.c b/src/lj_lex.c
index 8409cd78..5a918f74 100644
--- a/src/lj_lex.c
+++ b/src/lj_lex.c
@@ -214,6 +214,33 @@ static void lex_string(LexState *ls, TValue *tv)
214 c += 9; 214 c += 9;
215 } 215 }
216 break; 216 break;
217 case 'u': /* Unicode escape '\u{XX...}'. */
218 if (lex_next(ls) != '{') goto err_xesc;
219 lex_next(ls);
220 c = 0;
221 do {
222 c = (c << 4) | (ls->c & 15u);
223 if (!lj_char_isdigit(ls->c)) {
224 if (!lj_char_isxdigit(ls->c)) goto err_xesc;
225 c += 9;
226 }
227 if (c >= 0x110000) goto err_xesc; /* Out of Unicode range. */
228 } while (lex_next(ls) != '}');
229 if (c < 0x800) {
230 if (c < 0x80) break;
231 lex_save(ls, 0xc0 | (c >> 6));
232 } else {
233 if (c >= 0x10000) {
234 lex_save(ls, 0xf0 | (c >> 18));
235 lex_save(ls, 0x80 | ((c >> 12) & 0x3f));
236 } else {
237 if (c >= 0xd800 && c < 0xe000) goto err_xesc; /* No surrogates. */
238 lex_save(ls, 0xe0 | (c >> 12));
239 }
240 lex_save(ls, 0x80 | ((c >> 6) & 0x3f));
241 }
242 c = 0x80 | (c & 0x3f);
243 break;
217 case 'z': /* Skip whitespace. */ 244 case 'z': /* Skip whitespace. */
218 lex_next(ls); 245 lex_next(ls);
219 while (lj_char_isspace(ls->c)) 246 while (lj_char_isspace(ls->c))