I'm passing a string from Java to Python over a middleware and I'm evaluating the string to execute the method in python.
Let's say I send the below string from JAVA
'test_method("Value1", "Value2", **{"k1:":"v1", "k2":"v2"}'
This will be evaluated in python and the test_method with the arguments are called. This works fine until there is a single or a double qoute in any of the values. If v1 or v2, for example, has a single or a double quote, I get a syntax error during evaluation in python
I handle this by escaping all the characters while send from python.
I'm not sure if any SQL injection analogue can be present here. Can someone tell if it is safe to escape the quotes and backslashes ? If not, what is the recommended way of doing it.