[aur-dev] [PATCH 1/2] Check comment length in the backend
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/pkgbase.php | 7 +------ web/lib/pkgbasefuncs.inc.php | 4 ++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php index b98dc64..cbbf3cc 100644 --- a/web/html/pkgbase.php +++ b/web/html/pkgbase.php @@ -49,12 +49,7 @@ $output = ""; $fragment = ""; if (check_token()) { if (current_action("do_Flag")) { - if (strlen($_POST['comments']) >= 3) { - list($ret, $output) = pkgbase_flag($ids, $_POST['comments']); - } else { - $output = __("The selected packages have not been flagged, please enter a comment."); - $ret = false; - } + list($ret, $output) = pkgbase_flag($ids, $_POST['comments']); } elseif (current_action("do_UnFlag")) { list($ret, $output) = pkgbase_unflag($ids); } elseif (current_action("do_Adopt")) { diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index aad9d14..afccc7d 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -330,6 +330,10 @@ function pkgbase_flag($base_ids, $comment) { return array(false, __("You did not select any packages to flag.")); } + if (strlen($comment) < 3) { + return array(false, __("The selected packages have not been flagged, please enter a comment.")); + } + $uid = uid_from_sid($_COOKIE['AURSID']); $dbh = DB::connect(); -- 2.6.1
Fixes FS#46545. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/pkgflag.php | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/web/html/pkgflag.php b/web/html/pkgflag.php index b1ca03b..e6e7c64 100644 --- a/web/html/pkgflag.php +++ b/web/html/pkgflag.php @@ -8,6 +8,37 @@ include_once("pkgfuncs.inc.php"); set_lang(); check_sid(); +/* Grab the list of package base IDs to be operated on. */ +$ids = array(); +if (isset($_POST['IDs'])) { + foreach ($_POST['IDs'] as $id => $i) { + $id = intval($id); + if ($id > 0) { + $ids[] = $id; + } + } +} + +/* Perform package base actions. */ +$ret = false; +$output = ""; +if (check_token()) { + if (current_action("do_Flag")) { + list($ret, $output) = pkgbase_flag($ids, $_POST['comments']); + } + + if ($ret) { + header('Location: ' . get_pkgbase_uri($pkgbase_name) . $fragment); + exit(); + } +} + +/* Get default comment. */ +$comment = ''; +if (isset($_POST['comments'])) { + $comment = $_POST['comments']; +} + html_header(__("Flag Package Out-Of-Date")); if (has_credential(CRED_PKGBASE_FLAG)): ?> @@ -27,14 +58,19 @@ if (has_credential(CRED_PKGBASE_FLAG)): ?> '<strong>', '</strong>'); ?> <?= __('Enter details on why the package is out-of-date below, preferably including links to the release announcement or the new release tarball.'); ?> </p> - <form action="<?= get_pkgbase_uri($pkgbase_name); ?>" method="post"> + + <?php if ($output && !$ret): ?> + <ul class="errorlist"><li><?= htmlspecialchars($output) ?></li></ul> + <?php endif; ?> + + <form action="<?= get_pkgbase_uri($pkgbase_name); ?>flag/" method="post"> <fieldset> <input type="hidden" name="IDs[<?= $base_id ?>]" value="1" /> <input type="hidden" name="ID" value="<?= $base_id ?>" /> <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> <p> <label for="id_comments"><?= __("Comments") ?>:</label> - <textarea name="comments" id="id_comments" rows="5" cols="50"></textarea> + <textarea name="comments" id="id_comments" rows="5" cols="50"><?= htmlspecialchars($comment) ?></textarea> </p> <p><input type="submit" class="button" name="do_Flag" value="<?= __("Flag") ?>" /></p> </fieldset> -- 2.6.1
participants (1)
-
Lukas Fleischer