summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorMarcel Korpel <marcel.korpel@gmail.com>2015-08-17 00:08:52 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-08-17 04:20:45 +0200
commit095986b44974c569b36d34dd26902e910ccc7d8b (patch)
treecb4f0a10b5cd680fd06953f3c7431490a2e8da2a /web/lib
parent60433a930d6701cef1133cdb344fc76f24693636 (diff)
downloadaur-095986b44974c569b36d34dd26902e910ccc7d8b.tar.gz
aur-095986b44974c569b36d34dd26902e910ccc7d8b.tar.xz
Do not allow empty comments
Fixes FS#45870. Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgbasefuncs.inc.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index ccab635a..677ae6b8 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -81,6 +81,10 @@ function pkgbase_comments($base_id, $limit, $include_deleted) {
function pkgbase_add_comment($base_id, $uid, $comment) {
$dbh = DB::connect();
+ if (trim($comment) == '') {
+ return array(false, __('Comment cannot be empty.'));
+ }
+
$q = "INSERT INTO PackageComments ";
$q.= "(PackageBaseID, UsersID, Comments, CommentTS) VALUES (";
$q.= intval($base_id) . ", " . $uid . ", ";
@@ -102,6 +106,8 @@ function pkgbase_add_comment($base_id, $uid, $comment) {
if ($result) {
notify(array('comment', $uid, $base_id), $comment);
}
+
+ return array(true, __('Comment has been added.'));
}
/**
@@ -860,6 +866,10 @@ function pkgbase_edit_comment($comment) {
return array(false, __("Missing comment ID."));
}
+ if (trim($comment) == '') {
+ return array(false, __('Comment cannot be empty.'));
+ }
+
$dbh = DB::connect();
if (can_edit_comment($comment_id)) {
$q = "UPDATE PackageComments ";