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

rotru at br.ibm.com rotru at br.ibm.com
Wed Aug 26 04:09:35 UTC 2009


Hi, 

Just to let you know, 

I have had problems with mergerepo, so I applied all patch lines by 
myself. Mergerepo is working fine now,
but createrepo started to fail when I tried to create a local repo:

# createrepo -vd -o . -i ./pkglist -u http://myserver.com/packages -g 
/tmp/trujillo/comps.xml --update --skip-stat /mnt/koji/packages/
Scanning old repo data
Previous repo file missing: 
Traceback (most recent call last):
  File "/usr/share/createrepo/genpkgmetadata.py", line 233, in <module>
    main(sys.argv[1:])
  File "/usr/share/createrepo/genpkgmetadata.py", line 207, in main
    mdgen.doPkgMetadata()
  File "/usr/lib/python2.6/site-packages/createrepo/__init__.py", line 
364, in doPkgMetadata
    self.writeMetadataDocs(packages)
  File "/usr/lib/python2.6/site-packages/createrepo/__init__.py", line 
527, in writeMetadataDocs
    self.primaryfile.write(po.xml_dump_primary_metadata())
  File "/usr/lib/python2.6/site-packages/yum/packages.py", line 1015, in 
xml_dump_primary_metadata
    msg += misc.to_unicode(self._dump_format_items())
  File "/usr/lib/python2.6/site-packages/yum/packages.py", line 895, in 
_dump_format_items
    msg += self._dump_requires()
  File "/usr/lib/python2.6/site-packages/yum/packages.py", line 989, in 
_dump_requires
    prcostring += ''' pre="%s"''' % misc.to_xml(pre, attrib=True) #pre
  File "/usr/lib/python2.6/site-packages/yum/misc.py", line 778, in to_xml
    item = _ugly_utf8_string_hack(item)
  File "/usr/lib/python2.6/site-packages/yum/misc.py", line 744, in 
_ugly_utf8_string_hack
    x = unicode(item, 'ascii')
TypeError: coercing to Unicode: need string or buffer, int found


I dont know why, but the problem is in the "pre" value. It was '1' and was 
passed as an integer instead of string.
I worked around this transforming 'item' to string in misc.py

Rodrigo Trujillo




From:
Seth Vidal <skvidal at fedoraproject.org>
To:
yum development <yum-devel at lists.baseurl.org>
Date:
18/08/2009 12:15
Subject:
Re: [Yum-devel] [PATCH] ensure all attribute values are utf-8-encoded strs 
and properly xml-attribute-escaped




On Tue, 18 Aug 2009, Seth Vidal wrote:

>
>
> On Thu, 6 Aug 2009, Mike Bonnet wrote:
>> 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.
>
> agreed and will be committed shortly. Thank you.
>

actually, I take that back - all but a couple of lines of this patch had 
been applied already:

http://yum.baseurl.org/gitweb?p=yum.git;a=commitdiff;h=3e0325de50a1b5194d04d82db61f1d4170e5c370


but I applied the rest. Thank you.

-sv

_______________________________________________
Yum-devel mailing list
Yum-devel at lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20090826/a63947a4/attachment.htm>


More information about the Yum-devel mailing list