shithub: libmujs

Download patch

ref: 46aca3b4f8a71cda713b1619d83cd4fa9881b55b
parent: ee6c9c53f04f2489befc7fe78178182c8a59fbb7
author: Tor Andersson <tor.andersson@artifex.com>
date: Mon Oct 13 12:34:35 EDT 2014

Fix return value of RegExp.prototype.exec()

--- a/jsregexp.c
+++ b/jsregexp.c
@@ -48,6 +48,10 @@
 
 	if (!js_regexec(re->prog, text, &m, opts)) {
 		js_newarray(J);
+		js_pushstring(J, text);
+		js_setproperty(J, -2, "input");
+		js_pushnumber(J, js_utfptrtoidx(text, m.sub[0].sp));
+		js_setproperty(J, -2, "index");
 		for (i = 0; i < m.nsub; ++i) {
 			js_pushlstring(J, m.sub[i].sp, m.sub[i].ep - m.sub[i].sp);
 			js_setindex(J, -2, i);