summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-01-11 21:29:22 +0000
committerAlec Warner <antarus@gentoo.org>2007-01-11 21:29:22 +0000
commit49fffb5d3a94a5598f28355cb1b0ad169a31807f (patch)
treee19c1bfcee72fc7fe1e5173b85717d67f9765183
parentacc5d9c3421000d234c19ed3129a04f3decc589a (diff)
downloadportage-49fffb5d3a94a5598f28355cb1b0ad169a31807f.tar.gz
portage-49fffb5d3a94a5598f28355cb1b0ad169a31807f.tar.bz2
portage-49fffb5d3a94a5598f28355cb1b0ad169a31807f.zip
Valid categories in catpkgsplit
svn path=/main/trunk/; revision=5568
-rw-r--r--pym/portage_versions.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/pym/portage_versions.py b/pym/portage_versions.py
index 8e58c2f47..5cedd6504 100644
--- a/pym/portage_versions.py
+++ b/pym/portage_versions.py
@@ -249,7 +249,23 @@ def pkgsplit(mypkg,silent=1):
catcache={}
def catpkgsplit(mydata,silent=1):
- "returns [cat, pkgname, version, rev ]"
+ """
+ Takes a Category/Package-Version-Rev and returns a list of each.
+
+ @param mydata: Data to split
+ @type mydata: string
+ @param silent: suppress error messages
+ @type silent: Boolean (integer)
+ @rype: list
+ @return:
+ 1. If each exists, it returns [cat, pkgname, version, rev]
+ 2. If cat is not specificed in mydata, cat will be "null"
+ 3. if rev does not exist it will be '-r0'
+ 1. If the cat, pkg, or version is invalid, return None
+ """
+
+ # Categories may contain a-zA-z0-9+_- but cannot start with -
+ valid_category = re.compile("^[A-Za-z0-9+_][A-Za-z0-9+_-]*")
try:
if not catcache[mydata]:
return None
@@ -262,6 +278,8 @@ def catpkgsplit(mydata,silent=1):
retval=["null"]
p_split=pkgsplit(mydata,silent=silent)
elif len(mysplit)==2:
+ if not valid_category.match(mysplit[0]):
+ raise ValueError("Invalid category in %s" %mydata )
retval=[mysplit[0]]
p_split=pkgsplit(mysplit[1],silent=silent)
if not p_split: