From: Joerg Jaspert Date: Sat, 21 Feb 2009 19:42:56 +0000 (+0100) Subject: utf-8 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b481cd8cf9d18912aeb6c0af1e7ab883e347381e;p=dak utf-8 enforce properly encoded changes/dsc files. if they do not pass unicode() they wont get in. Signed-off-by: Joerg Jaspert --- diff --git a/dak/check_archive.py b/dak/check_archive.py index 80782908..bed974de 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -161,6 +161,9 @@ def check_dscs(): except InvalidDscError, line: utils.warn("syntax error in .dsc file '%s', line %s." % (f, line)) count += 1 + except ChangesUnicodeError: + utils.warn("found invalid changes file, not properly utf-8 encoded") + count += 1 if count: utils.warn("Found %s invalid .dsc files." % (count)) diff --git a/dak/check_proposed_updates.py b/dak/check_proposed_updates.py index f12df878..16a98763 100755 --- a/dak/check_proposed_updates.py +++ b/dak/check_proposed_updates.py @@ -176,6 +176,9 @@ def check_changes (filename): try: changes = utils.parse_changes(filename) files = utils.build_file_list(changes) + except ChangesUnicodeError: + utils.warn("Improperly encoded changes file, not utf-8") + return except: utils.warn("Error parsing changes file '%s'" % (filename)) return diff --git a/dak/examine_package.py b/dak/examine_package.py index d0e1e53a..eb602794 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -470,7 +470,10 @@ def display_changes(suite, changes_filename): foldable_output(changes_filename, "changes", changes, norow=True) def check_changes (changes_filename): - changes = utils.parse_changes (changes_filename) + try: + changes = utils.parse_changes (changes_filename) + except ChangesUnicodeError: + utils.warn("Encoding problem with changes file %s" % (changes_filename)) display_changes(changes['distribution'], changes_filename) files = utils.build_file_list(changes) diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index 2e60435d..288563af 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -186,6 +186,9 @@ def check_changes(): except ParseChangesError, line: reject("%s: parse error, can't grok: %s." % (filename, line)) return 0 + except ChangesUnicodeError: + reject("%s: changes file not proper utf-8" % (filename)) + return 0 # Parse the Files field from the .changes into another dictionary try: @@ -695,6 +698,9 @@ def check_dsc(): reject("%s: parse error, can't grok: %s." % (dsc_filename, line)) except InvalidDscError, line: reject("%s: syntax error on line %s." % (dsc_filename, line)) + except ChangesUnicodeError: + reject("%s: dsc file not proper utf-8." % (dsc_filename)) + # Build up the file list of files mentioned by the .dsc try: dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1)) diff --git a/daklib/dak_exceptions.py b/daklib/dak_exceptions.py index d18bee1e..33fa5ad3 100755 --- a/daklib/dak_exceptions.py +++ b/daklib/dak_exceptions.py @@ -58,7 +58,8 @@ dakerrors = { "NoFreeFilenameError": """Exception raised when no alternate filename was found.""", "TransitionsError": """Exception raised when transitions file can't be parsed.""", "NoSourceFieldError": """Exception raised - we cant find the source - wtf?""", - "DBUpdateError": """Exception raised - could not update the database""" + "DBUpdateError": """Exception raised - could not update the database""", + "ChangesUnicodeError": """Exception raised - changes file not properly utf-8 encoded""" } #: All dak exceptions def construct_dak_exception(name, description): diff --git a/daklib/utils.py b/daklib/utils.py index b20a063a..e0bdfe84 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -234,6 +234,10 @@ def parse_changes(filename, signing_rules=0): changes_in = open_file(filename) content = changes_in.read() changes_in.close() + try: + unicode(content, 'utf-8') + except UnicodeError: + raise ChangesUnicodeError, "Changes file not proper utf-8" return parse_deb822(content, signing_rules) ################################################################################