[XML-SIG] Bug in sgmlop? (_ in names)

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Wed, 5 Jul 2000 18:42:37 +0200


walter wrote:


> I finally found the time to try it with the new version from
> http://www.pythonware.com/products/xml/index.htm
> (sgmlop-000528.zip (Jun 28) (?))
> and the bug is still there.
>=20
> And I think I found a new one:

> import sgmlop
>=20
> class Handler:
>     def finish_starttag(self,name,attrs):
>        print name,attrs
>=20
> p =3D sgmlop.SGMLParser()
> p.register(Handler())
> p.parse("<foo_bar bar baz/>")
>=20
> results in
>=20
> foo {'_bar' : '_bar', 'baz': '', 'bar': 'bar'}
>=20
> So the attributes bar and baz seem to be treated differently.

the SGMLParser is designed to be compatible with sgmllib, and
sgmllib doesn't accept underscores in tag names.

> If using XMLParser instead of SGMLParser, the result is:
>=20
> foo_bar {'baz': '', 'bar': 'bar'}

this looks like a bug in attrparse (it probably works if you add
a space before the closing slash).  I'll post a patch as soon as
I have one...

cheers /F