[Yum-devel] [PATCH] ensure all attribute values are utf-8-encoded strs and properly xml-attribute-escaped

Mike Bonnet mikeb at redhat.com
Thu Aug 6 19:31:23 UTC 2009


On 08/06/2009 03:17 PM, James Antill wrote:
> On Tue, 2009-08-04 at 18:22 -0400, Mike Bonnet wrote:
>> When reading package metadata out of a database, sqlite returns unicode objects.
>
>   This seems fine, to me, from a correctness POV. However:
>
>> diff --git a/yum/packages.py b/yum/packages.py
>> index a7e81e6..af33d94 100644
>> --- a/yum/packages.py
>> +++ b/yum/packages.py
>> @@ -863,13 +863,13 @@ class YumAvailablePackage(PackageObject, RpmBase):
>>            for (name, flags, (e,v,r)) in mylist:
>>                pcostring = '''<rpm:entry name="%s"''' % misc.to_xml(name, attrib=True)
>>                if flags:
>> -                pcostring += ''' flags="%s"''' % flags
>> +                pcostring += ''' flags="%s"''' % misc.to_xml(flags, attrib=True)
>
>   Is it really necessary to use to_xml() instead of just to_utf8()? The
> obvious difference would be does that affect performance? I'm guessing
> it's probably fine, but any significant difference is going to add up on
> a rawhide compose.

In all of the instances here the values are being used in XML 
attributes, which is why I'm using to_xml(attrib=True).  This handles 
the case of a version or release containing a value not allowed in an 
attribute (a < or " for example).  Not likely, but possible.


More information about the Yum-devel mailing list