Unverified Commit b8fd598e by Tomáš Ďuriš Committed by GitHub

Warning on unknown escape sequences enabled by compiler argument (#223)

Co-authored-by: Tomáš Ďuriš <tomas.duris@avast.com>
parent 3abadbb2
......@@ -2624,7 +2624,7 @@ static PyObject* yara_compile(
{
static char *kwlist[] = {
"filepath", "source", "file", "filepaths", "sources",
"includes", "externals", "error_on_warning", "include_callback", NULL};
"includes", "externals", "error_on_warning", "strict_escape", "include_callback", NULL};
YR_COMPILER* compiler;
YR_RULES* yara_rules;
......@@ -2641,6 +2641,7 @@ static PyObject* yara_compile(
PyObject* includes = NULL;
PyObject* externals = NULL;
PyObject* error_on_warning = NULL;
PyObject* strict_escape = NULL;
PyObject* include_callback = NULL;
Py_ssize_t pos = 0;
......@@ -2657,7 +2658,7 @@ static PyObject* yara_compile(
if (PyArg_ParseTupleAndKeywords(
args,
keywords,
"|ssOOOOOOO",
"|ssOOOOOOOO",
kwlist,
&filepath,
&source,
......@@ -2667,6 +2668,7 @@ static PyObject* yara_compile(
&includes,
&externals,
&error_on_warning,
&strict_escape,
&include_callback))
{
char num_args = 0;
......@@ -2716,6 +2718,21 @@ static PyObject* yara_compile(
}
}
if (strict_escape != NULL)
{
if (PyBool_Check(strict_escape))
{
compiler->strict_escape = PyObject_IsTrue(strict_escape);
}
else
{
yr_compiler_destroy(compiler);
return PyErr_Format(
PyExc_TypeError,
"'strict_escape' param must be of boolean type");
}
}
if (includes != NULL)
{
if (PyBool_Check(includes))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment