[nanny] Fix gregexp bug with bad-formed utf8 strings



commit 9ca33145aeebd155b8f5627ed6b962552f6a54c9
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Fri May 14 22:44:30 2010 +0200

    Fix gregexp bug with bad-formed utf8 strings

 daemon/src/gregexmodule.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/daemon/src/gregexmodule.c b/daemon/src/gregexmodule.c
index a2ba580..b1e1e90 100644
--- a/daemon/src/gregexmodule.c
+++ b/daemon/src/gregexmodule.c
@@ -28,8 +28,10 @@ static PyObject*
 py_regexp(PyObject* self, PyObject* args){
         char *exp;
 	char *str;
-
-        PyArg_ParseTuple(args, "ss", &exp, &str);
+        if (!PyArg_ParseTuple(args, "es|es", "utf-8", &exp, "utf-8",  &str)) {
+		printf("gregexpodule (fail) : %s\n", exp);
+		return Py_BuildValue("i", FALSE);
+	}
         return Py_BuildValue("i", g_regex_match_simple(exp, str, 0, 0));
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]