Make Glsa constructor raise GlsaFormatException when a package name attribute
authorZac Medico <zmedico@gentoo.org>
Tue, 9 Feb 2010 03:20:45 +0000 (03:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 9 Feb 2010 03:20:45 +0000 (03:20 -0000)
is invalid.

svn path=/main/trunk/; revision=15328

pym/portage/glsa.py

index 4684ea420a77a887f7dbf66813d0f2f2707cc1bd..98602e4cc081d46f7389815f5601b5ce4a749a19 100644 (file)
@@ -11,6 +11,7 @@ except ImportError:
 import re
 import xml.dom.minidom
 
+import portage
 from portage import os
 from portage import _encodings
 from portage import _unicode_decode
@@ -551,6 +552,13 @@ class Glsa:
                self.packages = {}
                for p in self.affected.getElementsByTagName("package"):
                        name = p.getAttribute("name")
+                       try:
+                               name = portage.dep.Atom(name)
+                       except portage.exception.InvalidAtom:
+                               raise GlsaFormatException(_("invalid package name: %s") % name)
+                       if name != name.cp:
+                               raise GlsaFormatException(_("invalid package name: %s") % name)
+                       name = name.cp
                        if name not in self.packages:
                                self.packages[name] = []
                        tmp = {}