Oct-05-2020, 10:52 PM
Hi,
I'm using CGI to interact with form fields as shown in the example below:
v_inp (original)
After checking I do the assembly assigning the start and original value of the string:
I'm using CGI to interact with form fields as shown in the example below:
# Function -> Main method that receives parameters that handles request and response def application(environ, v_response): # Function -> Retrieves inputs from input forms a_inp = cgi.FieldStorage(environ["wsgi.input"], environ=environ)When testing if I can get the value entered from the fields using getvalue() I can get it without problems, as in the example below:
v_inp = a_inp.getlist("v_name")Having as answer the value entered in the form field:
return v_inp >> joaoIn the application I develop I need to check the variable (v_inp) to be able to go through a threat detection process of xss and sql injection (based on regular expressions, for this I use the (re) python module) to remove the characters (parentheses) of the string to avoid problems in passing threat detection, below I demonstrate the original and disassembled string:
v_inp (original)
v_inp = FieldStorage(None, None, [MiniFieldStorage('v_name', 'João')])v_inp (disassembled)
v_inp = FieldStorage None, None, [MiniFieldStorage 'v_name', 'João' ]Being disassembled according to the example above I can check if there is any threat from xss or sqlinjection to the passage through the threat detection process.
After checking I do the assembly assigning the start and original value of the string:
v_inp = FieldStorage(None, None, [MiniFieldStorage('v_name', 'João')])But I run into this error (AttributeError: 'str' object has no attribute 'getvalue') when trying to get the value of the field using the syntax below:
v_out = v_inp.getvalue("v_name") return v_outHow can I solve this problem?