cgi.py and HTML 4.0 compliancy

Juergen juergen at yellowbull.de
Tue Feb 6 10:11:05 EST 2001


Hello,

I am using PYTHON 2.0 and had a slight problem with the cgi module in
combination with HTML 4.0 compliant HTML code.

according to "validator.w3.org" the following URL is not HTML 4
compliant:
   <a href="mycgiscript.py?firstParam=Bill&secondParam=Whitters">Some
Text</a>

it seems that the "&" character between firstParam and secondParam is
not allowed.
I think the correct form of the above URL would be:
   <a href="mycgiscript.py?firstParam=Bill%26secondParam=Whitters">Some
Text</a>
but I am not sure. At least the validator doesn't complain anymore.

The problem with this URL is, that the cgi modules FieldStorage class
can't handle this format properly.

As a workaround I modified cgi.parse_qsl by adding a new line:

def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
    """Parse ....... intended.
    """
    qs = qs.replace('%26','&')    # had to add this line to make it HTML
4.0 compliant.
    pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
    ...

For my purpose this is good enough. I just want to generate HTML code
that passes w3's validator.

I wonder if some Python core developer should take care of this or if
the HTML validator needs to be fixed.

Any opinions ?

Juergen


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list