mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
python: py_strcasecmp_m & py_strstr_m don't handle unicode properly
py_strcasecmp_m & py_strstr_m use PyArg_ParseTuple() with 's' which in Py2 tries to decode string with the default (e.g. ascii) encoding Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
95dbe1177f
commit
2323972773
@ -297,26 +297,30 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject *py_strcasecmp_m(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *s1, *s2;
|
||||
const char *s1 = NULL;
|
||||
const char *s2 = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss", &s1, &s2))
|
||||
if (!PyArg_ParseTuple(args, "eses", "utf8", &s1, "utf8", &s2)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyInt_FromLong(strcasecmp_m(s1, s2));
|
||||
}
|
||||
|
||||
static PyObject *py_strstr_m(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *s1, *s2, *ret;
|
||||
const char *s1 = NULL;
|
||||
const char *s2 = NULL;
|
||||
char *ret = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss", &s1, &s2))
|
||||
if (!PyArg_ParseTuple(args, "eses", "utf8", &s1, "utf8", &s2))
|
||||
return NULL;
|
||||
|
||||
ret = strstr_m(s1, s2);
|
||||
if (!ret) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
return PyStr_FromString(ret);
|
||||
return PyUnicode_FromString(ret);
|
||||
}
|
||||
|
||||
static PyMethodDef py_misc_methods[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user