shithub: libmujs

Download patch

ref: 43384d9110fc552d12d59993bcc4d07a20b6e0ce
parent: 9cb65f0e370c2b14f9a19314289c405312393cde
author: Tor Andersson <tor@ccxvii.net>
date: Thu Feb 27 08:12:28 EST 2014

Parse \0 and \x00 and \u0000 in regular expressions.

Still doesn't match them, due to our use of zero-terminated strings.

--- a/regex.c
+++ b/regex.c
@@ -117,6 +117,10 @@
 		case 'x':
 			g->yychar = hex(g, *g->source++) << 4;
 			g->yychar += hex(g, *g->source++);
+			if (g->yychar == 0) {
+				g->yychar = '0';
+				return 1;
+			}
 			return 0;
 		case 'u':
 			g->yychar = hex(g, *g->source++) << 12;
@@ -123,6 +127,10 @@
 			g->yychar += hex(g, *g->source++) << 8;
 			g->yychar += hex(g, *g->source++) << 4;
 			g->yychar += hex(g, *g->source++);
+			if (g->yychar == 0) {
+				g->yychar = '0';
+				return 1;
+			}
 			return 0;
 		}
 		if (!strchr(ESCAPES, g->yychar))
@@ -285,8 +293,11 @@
 			if (quoted) {
 				if (g->yychar == 'b')
 					g->yychar = '\b';
+				else if (g->yychar == '0')
+					g->yychar = 0;
 				else
 					die(g, "invalid escape character");
+			}
 			if (havesave) {
 				if (havedash) {
 					addrange(g, save, g->yychar);