From 56a80483e9a142a6c21d9841a16a15ecfbd30b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 5 Feb 2014 09:29:26 +0100 Subject: [PATCH] Make f-droid barf on unrecognised field names --- fdroidserver/metadata.py | 63 ++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 168113f4..ce1fcecb 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -28,6 +28,38 @@ class MetaDataException(Exception): def __str__(self): return repr(self.value) +app_defaults = { + 'Name': None, + 'Provides': None, + 'Auto Name': '', + 'Categories': 'None', + 'Description': [], + 'Summary': '', + 'License': 'Unknown', + 'Web Site': '', + 'Source Code': '', + 'Issue Tracker': '', + 'Donate': None, + 'FlattrID': None, + 'Bitcoin': None, + 'Litecoin': None, + 'Dogecoin': None, + 'Disabled': None, + 'AntiFeatures': None, + 'Archive Policy': None, + 'Update Check Mode': 'None', + 'Update Check Data': None, + 'Vercode Operation': None, + 'Auto Update Mode': 'None', + 'Current Version': '', + 'Current Version Code': '0', + 'Repo Type': '', + 'Repo': '', + 'Requires Root': False, + 'No Source Since': '' +} + + # Designates a metadata field type and checks that it matches # # 'name' - The long name of the field type @@ -404,6 +436,8 @@ def metafieldtype(name): return 'buildv2' if name == 'Use Built': return 'obsolete' + if name not in app_defaults: + return 'unknown' return 'string' # Parse metadata for a single application. @@ -485,34 +519,7 @@ def parse_metadata(metafile): else: thisinfo['id'] = None - # Defaults for fields that come from metadata... - thisinfo['Name'] = None - thisinfo['Provides'] = None - thisinfo['Auto Name'] = '' - thisinfo['Categories'] = 'None' - thisinfo['Description'] = [] - thisinfo['Summary'] = '' - thisinfo['License'] = 'Unknown' - thisinfo['Web Site'] = '' - thisinfo['Source Code'] = '' - thisinfo['Issue Tracker'] = '' - thisinfo['Donate'] = None - thisinfo['FlattrID'] = None - thisinfo['Bitcoin'] = None - thisinfo['Litecoin'] = None - thisinfo['Dogecoin'] = None - thisinfo['Disabled'] = None - thisinfo['AntiFeatures'] = None - thisinfo['Archive Policy'] = None - thisinfo['Update Check Mode'] = 'None' - thisinfo['Vercode Operation'] = None - thisinfo['Auto Update Mode'] = 'None' - thisinfo['Current Version'] = '' - thisinfo['Current Version Code'] = '0' - thisinfo['Repo Type'] = '' - thisinfo['Repo'] = '' - thisinfo['Requires Root'] = False - thisinfo['No Source Since'] = '' + thisinfo.update(app_defaults) # General defaults... thisinfo['builds'] = []