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

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Wed, 5 Jul 2000 22:16:03 +0200


I wrote:

> > 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...

here's one:

...

diff -u sgmlop.c~ sgmlop.c
--- sgmlop.c~ Sun May 28 20:14:01 2000
+++ sgmlop.c Wed Jul 05 22:09:01 2000
@@ -23,6 +23,7 @@
  * 2000-05-28 fl  Added temporary workaround for unicode problem =
(@SGMLOP2)
  * 2000-05-28 fl  Removed optional close argument (@SGMLOP3)
  * 2000-05-28 fl  Raise exception on recursive feed (@SGMLOP4)
+ * 2000-07-05 fl  Fixed attribute handling in empty tags (@SGMLOP6)
  *
  * Copyright (c) 1998-2000 by Secret Labs AB
  * Copyright (c) 1998-2000 by Fredrik Lundh
@@ -972,7 +973,7 @@
             if (!self->xml)
                 while (ISALNUM(*p) || *p =3D=3D '-' || *p =3D=3D '.' ||
                        *p =3D=3D ':' || *p =3D=3D '?') {
-                    *p =3D TOLOWER(*p);
+                    *p =3D (CHAR_T) TOLOWER(*p);
                     if (++p >=3D end)
                         goto eol;
                 }
@@ -1199,7 +1200,7 @@
                 CHAR_T *p;
                 ch =3D 0;
                 for (p =3D b; p < e; p++)
-                    ch =3D ch*10 + *p - '0';
+                    ch =3D (CHAR_T) (ch*10 + *p - '0');
                 res =3D PyObject_CallFunction(self->handle_data,
                                             "s#", &ch, sizeof(CHAR_T));
             }
@@ -1278,18 +1279,18 @@
         if (key =3D=3D NULL)
             goto err;
=20
+        if (xml)
+            value =3D Py_None;
+        else
+            value =3D key; /* in SGML mode, default is same as key */
+
         while (p < end && ISSPACE(*p))
             p++;
=20
-        if (p < end && *p !=3D '=3D') {
-
-            /* attribute value not specified: set value to name */
-            value =3D key;
-            Py_INCREF(value);
-
-        } else {
+        if (p < end && *p =3D=3D '=3D') {
=20
             /* attribute value found */
+            Py_DECREF(value);
=20
             if (p < end)
                 p++;

...

</F>