From 6bbf0a1722c51f16788fd8cab44136ff5ba04f73 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 16 Jun 2020 14:39:46 +0200 Subject: [PATCH] add Liberapay: field with username as data Liberapay was originally included using a numeric ID, since they had not yet finalized the public URLs. Now it is a username. So this logic prefers the username in Liberapay: field, and keeps the old LiberapayID: to ease migration. LiberapayID: will not override Liberapay:. Clients are expected to prefer Liberapay: over LiberapayID: # Conflicts: # fdroidserver/update.py # tests/metadata/info.guardianproject.checkey.yml # tests/metadata/obb.main.oldversion.yml # tests/metadata/org.adaway.yml # tests/update.TestCase --- .gitlab-ci.yml | 2 +- fdroidserver/lint.py | 6 ++++-- fdroidserver/metadata.py | 11 +++++++++++ tests/metadata/dump/com.politedroid.yaml | 1 + tests/metadata/dump/org.adaway.yaml | 3 ++- tests/metadata/dump/org.smssecure.smssecure.yaml | 1 + tests/metadata/dump/org.videolan.vlc.yaml | 1 + tests/metadata/info.guardianproject.checkey.txt | 1 + tests/metadata/obb.main.oldversion.txt | 1 + tests/metadata/org.adaway.json | 1 + tests/repo/index-v1.json | 1 + 11 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5274a68c..1507e504 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,7 +33,7 @@ metadata_v0: - echo "accepted_formats = ('txt', 'yml')" >> config.py - ../tests/dump_internal_metadata_format.py - sed -i - -e '/kivy:\sfalse/d' + -e '/Liberapay:/d' -e '/OpenCollective/d' metadata/dump_*/*.yaml - diff -uw metadata/dump_* diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index 465954cc..6f8a768e 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -139,9 +139,11 @@ regex_checks = { ], 'Donate': http_checks + [ (re.compile(r'.*flattr\.com'), - _("Flattr donation methods belong in the FlattrID flag")), + _("Flattr donation methods belong in the FlattrID: field")), (re.compile(r'.*liberapay\.com'), - _("Liberapay donation methods belong in the LiberapayID flag")), + _("Liberapay donation methods belong in the Liberapay: field")), + (re.compile(r'.*opencollective\.com'), + _("OpenCollective donation methods belong in the OpenCollective: field")), ], 'Changelog': http_checks, 'Author Name': [ diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 00056d14..14a6f512 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -36,6 +36,10 @@ from fdroidserver.exception import MetaDataException, FDroidException srclibs = None warnings_action = None +# validates usernames based on a loose collection of rules from GitHub, GitLab, +# Liberapay and issuehunt. This is mostly to block abuse. +VALID_USERNAME_REGEX = re.compile(r'^[a-z\d](?:[a-z\d/._-]){0,38}$', re.IGNORECASE) + def warn_or_exception(value): '''output warning or Exception depending on -W''' @@ -65,6 +69,7 @@ app_fields = set([ 'Changelog', 'Donate', 'FlattrID', + 'Liberapay', 'LiberapayID', 'OpenCollective', 'Bitcoin', @@ -110,6 +115,7 @@ yaml_app_field_order = [ 'Changelog', 'Donate', 'FlattrID', + 'Liberapay', 'LiberapayID', 'OpenCollective', 'Bitcoin', @@ -170,6 +176,7 @@ class App(dict): self.Changelog = '' self.Donate = None self.FlattrID = None + self.Liberapay = None self.LiberapayID = None self.OpenCollective = None self.Bitcoin = None @@ -443,6 +450,10 @@ valuetypes = { r'^[0-9a-z]+$', ['FlattrID']), + FieldValidator("Liberapay", + VALID_USERNAME_REGEX, + ['Liberapay']), + FieldValidator("Liberapay ID", r'^[0-9]+$', ['LiberapayID']), diff --git a/tests/metadata/dump/com.politedroid.yaml b/tests/metadata/dump/com.politedroid.yaml index 5d80e30e..4837a93c 100644 --- a/tests/metadata/dump/com.politedroid.yaml +++ b/tests/metadata/dump/com.politedroid.yaml @@ -17,6 +17,7 @@ Disabled: null Donate: null FlattrID: null IssueTracker: https://github.com/miguelvps/PoliteDroid/issues +Liberapay: null LiberapayID: null License: GPL-3.0-only Litecoin: null diff --git a/tests/metadata/dump/org.adaway.yaml b/tests/metadata/dump/org.adaway.yaml index 6412aaa3..ebabcb37 100644 --- a/tests/metadata/dump/org.adaway.yaml +++ b/tests/metadata/dump/org.adaway.yaml @@ -40,7 +40,8 @@ Disabled: null Donate: http://sufficientlysecure.org/index.php/adaway FlattrID: '369138' IssueTracker: https://github.com/dschuermann/ad-away/issues -LiberapayID: null +Liberapay: null +LiberapayID: '1234567890' License: GPL-3.0-only Litecoin: null MaintainerNotes: '' diff --git a/tests/metadata/dump/org.smssecure.smssecure.yaml b/tests/metadata/dump/org.smssecure.smssecure.yaml index 688e7d26..a979e9c1 100644 --- a/tests/metadata/dump/org.smssecure.smssecure.yaml +++ b/tests/metadata/dump/org.smssecure.smssecure.yaml @@ -37,6 +37,7 @@ Disabled: null Donate: null FlattrID: null IssueTracker: https://github.com/SMSSecure/SMSSecure/issues +Liberapay: null LiberapayID: null License: GPL-3.0-only Litecoin: null diff --git a/tests/metadata/dump/org.videolan.vlc.yaml b/tests/metadata/dump/org.videolan.vlc.yaml index 5ab8783d..39d628d4 100644 --- a/tests/metadata/dump/org.videolan.vlc.yaml +++ b/tests/metadata/dump/org.videolan.vlc.yaml @@ -24,6 +24,7 @@ Disabled: null Donate: http://www.videolan.org/contribute.html#money FlattrID: null IssueTracker: http://www.videolan.org/support/index.html#bugs +Liberapay: null LiberapayID: null License: GPL-3.0-only Litecoin: null diff --git a/tests/metadata/info.guardianproject.checkey.txt b/tests/metadata/info.guardianproject.checkey.txt index c6d7557c..1ad98833 100644 --- a/tests/metadata/info.guardianproject.checkey.txt +++ b/tests/metadata/info.guardianproject.checkey.txt @@ -5,6 +5,7 @@ Source Code:https://github.com/guardianproject/checkey Issue Tracker:https://dev.guardianproject.info/projects/checkey/issues Translation:https://www.transifex.com/otf/checkey Bitcoin:1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk +Liberapay:GuardianProject Auto Name:Checkey diff --git a/tests/metadata/obb.main.oldversion.txt b/tests/metadata/obb.main.oldversion.txt index 0a4e4956..52095f10 100644 --- a/tests/metadata/obb.main.oldversion.txt +++ b/tests/metadata/obb.main.oldversion.txt @@ -2,6 +2,7 @@ Categories:Development License:GPL-3.0-only Source Code:https://github.com/eighthave/urzip Bitcoin:1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk +Liberapay:12334 Auto Name:OBB Main Old Version diff --git a/tests/metadata/org.adaway.json b/tests/metadata/org.adaway.json index df71f112..c74017f5 100644 --- a/tests/metadata/org.adaway.json +++ b/tests/metadata/org.adaway.json @@ -22,6 +22,7 @@ "Donate": "http://sufficientlysecure.org/index.php/adaway", "FlattrID": "369138", "IssueTracker": "https://github.com/dschuermann/ad-away/issues", + "LiberapayID": "1234567890", "License": "GPL-3.0-only", "Provides": "org.sufficientlysecure.adaway", "Repo": "https://github.com/dschuermann/ad-away.git", diff --git a/tests/repo/index-v1.json b/tests/repo/index-v1.json index f69e7aec..9ce9ddb9 100644 --- a/tests/repo/index-v1.json +++ b/tests/repo/index-v1.json @@ -104,6 +104,7 @@ "Development" ], "suggestedVersionCode": "99999999", + "liberapay": "12334", "license": "GPL-3.0-only", "name": "OBB Main Old Version", "sourceCode": "https://github.com/eighthave/urzip",