summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2012-08-23 20:06:10 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2012-08-23 22:47:50 +0200
commit44d8588b6304c12ef8ae8b3151a697a73dce526d (patch)
treeacef07359f73fe91be559e1e8a4e6fcc131f66a5
parent362d49a796decc75bc7c6438110a63427563d4b1 (diff)
downloadaur-44d8588b6304c12ef8ae8b3151a697a73dce526d.tar.gz
aur-44d8588b6304c12ef8ae8b3151a697a73dce526d.tar.xz
Print error message when maximum DB character length is exceeded
Packages can currently be submitted with variables longer than the maximum allowed by the DB for that specific field. The string will be shortened without informing the user. This can result in unexpected oddities on submitted packages. Print error messages informing the user when the package name, URL, description, license, or version is too long. Also move the resolution of full package version (including epoch) to an earlier point in pkgsubmit.php Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r--web/html/pkgsubmit.php35
1 files changed, 29 insertions, 6 deletions
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index e87279ea..b2a26f78 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -277,6 +277,35 @@ if ($uid):
}
}
+ # Determine the full package version with epoch
+ if (!$error) {
+ if (isset($new_pkgbuild['epoch']) && (int)$new_pkgbuild['epoch'] > 0) {
+ $pkg_version = sprintf('%d:%s-%s', $new_pkgbuild['epoch'], $new_pkgbuild['pkgver'], $new_pkgbuild['pkgrel']);
+ } else {
+ $pkg_version = sprintf('%s-%s', $new_pkgbuild['pkgver'], $new_pkgbuild['pkgrel']);
+ }
+ }
+
+ # The DB schema imposes limitations on number of allowed characters
+ # Print error message when these limitations are exceeded
+ if (!$error) {
+ if (strlen($pkg_name) > 64) {
+ $error = __("Error - Package name cannot be greater than %d characters", 64);
+ }
+ if (strlen($new_pkgbuild['url']) > 255) {
+ $error = __("Error - Package URL cannot be greater than %d characters", 255);
+ }
+ if (strlen($new_pkgbuild['pkgdesc']) > 255) {
+ $error = __("Error - Package description cannot be greater than %d characters", 255);
+ }
+ if (strlen($new_pkgbuild['license']) > 40) {
+ $error = __("Error - Package license cannot be greater than %d characters", 40);
+ }
+ if (strlen($pkg_version) > 32) {
+ $error = __("Error - Package version cannot be greater than %d characters", 32);
+ }
+ }
+
if (isset($pkg_name)) {
$incoming_pkgdir = INCOMING_DIR . substr($pkg_name, 0, 2) . "/" . $pkg_name;
}
@@ -324,12 +353,6 @@ if ($uid):
$pdata = pkgdetails_by_pkgname($new_pkgbuild['pkgname'], $dbh);
- if (isset($new_pkgbuild['epoch']) && (int)$new_pkgbuild['epoch'] > 0) {
- $pkg_version = sprintf('%d:%s-%s', $new_pkgbuild['epoch'], $new_pkgbuild['pkgver'], $new_pkgbuild['pkgrel']);
- } else {
- $pkg_version = sprintf('%s-%s', $new_pkgbuild['pkgver'], $new_pkgbuild['pkgrel']);
- }
-
# Check the category to use, "1" meaning "none" (or "keep category" for
# existing packages).
if (isset($_POST['category'])) {