[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Fix for the DEP-11 validation issue



Hi!
Looks like the DEP-11 validation code has a bug, which makes dak Arf at me ^^

The patches I attached will fix this issue (first patch) and also
validate the .xz files (second patch).

Cheers,
    Matthias

-- 
I welcome VSRE emails. See http://vsre.info/
From 28d9758f55a4aa18cd2b68e7450a2d7405aa0036 Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <matthias@tenstral.net>
Date: Wed, 18 May 2016 22:11:20 +0200
Subject: [PATCH 2/2] dep11: Validate .xz compressed files as well

---
 scripts/debian/dep11-basic-validate.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/debian/dep11-basic-validate.py b/scripts/debian/dep11-basic-validate.py
index 870c4f3..03cd80c 100755
--- a/scripts/debian/dep11-basic-validate.py
+++ b/scripts/debian/dep11-basic-validate.py
@@ -19,6 +19,7 @@ import os
 import sys
 import yaml
 import gzip
+import lzma
 from voluptuous import Schema, Required, All, Any, Length, Range, Match, Url
 from optparse import OptionParser
 
@@ -154,6 +155,8 @@ def validate_file(fname):
     f = None
     if fname.endswith(".gz"):
         f = gzip.open(fname, 'r')
+    elif fname.endswith(".xz"):
+        f = lzma.open(fname, 'r')
     else:
         f = open(fname, 'r')
 
@@ -166,7 +169,7 @@ def validate_dir(dirname):
     ret = True
     for root, subfolders, files in os.walk(dirname):
         for fname in files:
-             if fname.endswith(".yml.gz"):
+             if fname.endswith(".yml.gz") or fname.endswith(".yml.xz"):
                  if not validate_file(os.path.join(root, fname)):
                      ret = False
 
-- 
2.7.4

From 70451ecbcbfcc1a44aefa1e6f2cba9b495f41c2d Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <matthias@tenstral.net>
Date: Wed, 18 May 2016 22:11:00 +0200
Subject: [PATCH 1/2] dep11: Properly validate Time and Priority fields

---
 scripts/debian/dep11-basic-validate.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/debian/dep11-basic-validate.py b/scripts/debian/dep11-basic-validate.py
index 6f46e14..870c4f3 100755
--- a/scripts/debian/dep11-basic-validate.py
+++ b/scripts/debian/dep11-basic-validate.py
@@ -27,8 +27,8 @@ schema_header = Schema({
     Required('Origin'): All(str, Length(min=1)),
     Required('Version'): All(str, Match(r'(\d+\.?)+$'), msg="Must be a valid version number"),
     Required('MediaBaseUrl'): All(str, Url()),
-    'Time': All(str, str),
-    'Priority': All(str, int),
+    'Time': All(str),
+    'Priority': All(int),
 })
 
 schema_translated = Schema({
-- 
2.7.4


Reply to: