summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-09-11 21:46:43 -0700
committerZac Medico <zmedico@gentoo.org>2012-09-11 21:46:43 -0700
commit6d1ed6df57e6167fee9c6fc30fa889f27042043e (patch)
tree61635b0d3dd6852aacf25d2a6515afe56d10f80e
parentAdd EAPI 5_pre2 with features approved by council (diff)
downloadportage-6d1ed6df57e6167fee9c6fc30fa889f27042043e.tar.gz
portage-6d1ed6df57e6167fee9c6fc30fa889f27042043e.tar.bz2
portage-6d1ed6df57e6167fee9c6fc30fa889f27042043e.zip
MetaDataXML: encode unicode file paths safely
This will fix cases similar to the one fixed in commit f01d7a8ca158ec60df76a3e8ae5b80ac3f62429e for bug #310789.
-rw-r--r--pym/portage/xml/metadata.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/pym/portage/xml/metadata.py b/pym/portage/xml/metadata.py
index f820e5414..113b118a4 100644
--- a/pym/portage/xml/metadata.py
+++ b/pym/portage/xml/metadata.py
@@ -58,8 +58,7 @@ except (ImportError, SystemError, RuntimeError, Exception):
import re
import xml.etree.ElementTree
-import portage
-from portage import os, _unicode_decode
+from portage import _encodings, _unicode_encode, _unicode_decode
from portage.util import unique_everseen
class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
@@ -203,7 +202,8 @@ class MetaDataXML(object):
self._xml_tree = None
try:
- self._xml_tree = etree.parse(metadata_xml_path,
+ self._xml_tree = etree.parse(_unicode_encode(metadata_xml_path,
+ encoding=_encodings['fs'], errors='strict'),
parser=etree.XMLParser(target=_MetadataTreeBuilder()))
except ImportError:
pass
@@ -241,7 +241,8 @@ class MetaDataXML(object):
if self._herdstree is None:
try:
- self._herdstree = etree.parse(self._herds_path,
+ self._herdstree = etree.parse(_unicode_encode(self._herds_path,
+ encoding=_encodings['fs'], errors='strict'),
parser=etree.XMLParser(target=_MetadataTreeBuilder()))
except (ImportError, IOError, SyntaxError):
return None