[aur-dev] [PATCH v2 1/2] git-update: Remove regex matching of URL
The regex check that a URL is either http or ftp doesn't really have any use, and it forces you leave proper URLs like projects hosted on gopher still empty. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- git-interface/git-update.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/git-interface/git-update.py b/git-interface/git-update.py index ebed491..6610019 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -258,9 +258,6 @@ for commit in walker: die_commit('invalid package name: %s' % (pkginfo['pkgname']), commit.id) - if not re.match(r'(?:http|ftp)s?://.*', pkginfo['url']): - die_commit('invalid URL: %s' % (pkginfo['url']), commit.id) - for field in ('pkgname', 'pkgdesc', 'url'): if len(pkginfo[field]) > 255: die_commit('%s field too long: %s' % (field, pkginfo[field]), -- 2.4.3
The url and pkgdesc PKGBUILD variables are optional, so should be in the AUR as well. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- git-interface/git-update.py | 8 ++++++-- web/template/pkg_details.php | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/git-interface/git-update.py b/git-interface/git-update.py index 6610019..b9f960f 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -247,10 +247,14 @@ for commit in walker: for pkgname in srcinfo.GetPackageNames(): pkginfo = srcinfo.GetMergedPackage(pkgname) - for field in ('pkgver', 'pkgrel', 'pkgname', 'pkgdesc', 'url'): + for field in ('pkgver', 'pkgrel', 'pkgname'): if not field in pkginfo: die_commit('missing mandatory field: %s' % (field), commit.id) + for field in ('pkgdesc', 'url'): + if not field in pkginfo: + pkginfo[field] = 'NULL' + if 'epoch' in pkginfo and not pkginfo['epoch'].isdigit(): die_commit('invalid epoch: %s' % (pkginfo['epoch']), commit.id) @@ -259,7 +263,7 @@ for commit in walker: commit.id) for field in ('pkgname', 'pkgdesc', 'url'): - if len(pkginfo[field]) > 255: + if field in pkginfo and len(pkginfo[field]) > 255: die_commit('%s field too long: %s' % (field, pkginfo[field]), commit.id) diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 2f121e7..963504d 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -183,11 +183,19 @@ $sources = pkg_sources($row["ID"]); </tr> <tr> <th><?= __('Description') . ': ' ?></th> +<?php if ($row['Description'] != 'NULL'): ?> <td class="wrap"><?= htmlspecialchars($row['Description']); ?></td> +<?php else: ?> + <td class="wrap"><?= __('None') ?></td> +<?php endif; ?> </tr> <tr> <th><?= __('Upstream URL') . ': ' ?></th> +<?php if ($row['URL'] != 'NULL'): ?> <td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td> +<?php else: ?> + <td class="wrap"><?= __('None') ?></td> +<?php endif; ?> </tr> <?php if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"])) || count($keywords) > 0): -- 2.4.3
The url and pkgdesc PKGBUILD variables are optional, so should be in the AUR as well. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- Changes since v2: * Use None type which is converted into NULL by mysql.connect * Remove NOT NULL from schema * Move `pkginfo[field] = None` to right part of the code * Use empty() git-interface/git-update.py | 8 ++++++-- schema/aur-schema.sql | 4 ++-- web/template/pkg_details.php | 8 ++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/git-interface/git-update.py b/git-interface/git-update.py index 6610019..41a3474 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -77,6 +77,10 @@ def save_srcinfo(srcinfo, db, cur, user): else: ver = '%s-%s' % (pkginfo['pkgver'], pkginfo['pkgrel']) + for field in ('pkgdesc', 'url'): + if not field in pkginfo: + pkginfo[field] = None + # Create a new package. cur.execute("INSERT INTO Packages (PackageBaseID, Name, " + "Version, Description, URL) " + @@ -247,7 +251,7 @@ for commit in walker: for pkgname in srcinfo.GetPackageNames(): pkginfo = srcinfo.GetMergedPackage(pkgname) - for field in ('pkgver', 'pkgrel', 'pkgname', 'pkgdesc', 'url'): + for field in ('pkgver', 'pkgrel', 'pkgname'): if not field in pkginfo: die_commit('missing mandatory field: %s' % (field), commit.id) @@ -259,7 +263,7 @@ for commit in walker: commit.id) for field in ('pkgname', 'pkgdesc', 'url'): - if len(pkginfo[field]) > 255: + if field in pkginfo and len(pkginfo[field]) > 255: die_commit('%s field too long: %s' % (field, pkginfo[field]), commit.id) diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 5a702b2..69d3bf8 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -107,8 +107,8 @@ CREATE TABLE Packages ( PackageBaseID INTEGER UNSIGNED NOT NULL, Name VARCHAR(255) NOT NULL, Version VARCHAR(255) NOT NULL DEFAULT '', - Description VARCHAR(255) NOT NULL DEFAULT "An Arch Package", - URL VARCHAR(255) NOT NULL DEFAULT "https://www.archlinux.org", + Description VARCHAR(255) DEFAULT "An Arch Package", + URL VARCHAR(255) DEFAULT "https://www.archlinux.org", PRIMARY KEY (ID), UNIQUE (Name), FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 2f121e7..33d999b 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -183,11 +183,19 @@ $sources = pkg_sources($row["ID"]); </tr> <tr> <th><?= __('Description') . ': ' ?></th> +<?php if (!empty($row['Description'])): ?> <td class="wrap"><?= htmlspecialchars($row['Description']); ?></td> +<?php else: ?> + <td class="wrap"><?= __('None') ?></td> +<?php endif; ?> </tr> <tr> <th><?= __('Upstream URL') . ': ' ?></th> +<?php if (!empty($row['URL'])): ?> <td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td> +<?php else: ?> + <td class="wrap"><?= __('None') ?></td> +<?php endif; ?> </tr> <?php if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"])) || count($keywords) > 0): -- 2.4.3
participants (1)
-
Johannes Löthberg