Set empty limit to "" in serendipity_fetchEntries.

If $limit is empty(), no limit is set, so we can
set the LIMIT statement to "" to achieve the same.

But an empty() $limit can be "0", so the
generated SQL statement could end with "0"
instead of the LIMIT statement. We catch this
with forcing an empty() $limit to "".

Fixes #636.
(No matter that this shouldn't even happen.)

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein 2020-03-21 17:52:33 +01:00
parent 95c71c36c9
commit 1632a172f3
2 changed files with 14 additions and 0 deletions

View File

@ -21,6 +21,11 @@ Version 2.3.3-beta1 ()
* Fix: Add valid HTTP referrer when trying to delete a
* Fix: Wordwrap at word boundaries only in bundled plugin
serendipity_plugin_comments.
* Fix: Force empty limit to "" in serendipity_fetchEntries().
* Fix: Escape version string in update notifier to avoid XSS.
* Fix: Prevent renaming a ML object into an existing file,

View File

@ -433,6 +433,15 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
}
$limit = serendipity_db_limit_sql($limit);
} else {
# if $limit was empty(), no limit was set;
# but empty() may also mean FALSE, "" or 0,
# so set it to "" to remove the LIMIT
# statement completely; should catch errors
# with a limit of 0 and some database drivers
# see <https://github.com/s9y/Serendipity/issues/636>
$limit = '';
}
$query = "SELECT $select_key