Is unwanted characters removal enough to prevent most attacks (Python) ? Obviously the code should have more sophisticated rules (ex.remove more than one consecutive white spaces after a new line), but my understanding is that only characters used in programming can enable code injection and I want to make sure I am not missing cases where code injection can happen even with no such characters .
# initializing bad_chars_list
bad_chars = [';', ':', '!', "*","("]
# initializing test string
test_string = "Examp;l * int s=10;"
# printing original string
print ("Original String : " + test_string)
# using replace() to
# remove bad_chars
for i in bad_chars :
test_string = test_string.replace(i, '')