mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-15 22:11:17 +02:00
more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
This commit is contained in:
@@ -356,7 +356,7 @@ define('forum/topic', [
|
||||
)
|
||||
) {
|
||||
if (app.user.uid) {
|
||||
ajaxify.data.bookmark = index;
|
||||
ajaxify.data.bookmark = Math.min(index, ajaxify.data.postcount);
|
||||
|
||||
socket.emit('topics.bookmark', {
|
||||
tid: ajaxify.data.tid,
|
||||
|
||||
@@ -355,7 +355,7 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts', 'trans
|
||||
return;
|
||||
}
|
||||
|
||||
index = Math.max(index, ajaxify.data.bookmark);
|
||||
index = Math.max(index, Math.min(ajaxify.data.bookmark, ajaxify.data.postcount));
|
||||
const unreadEl = paginationBlockUnreadEl.get(0);
|
||||
const trackEl = unreadEl.parentNode;
|
||||
const trackHeight = trackEl.getBoundingClientRect().height;
|
||||
|
||||
@@ -35,7 +35,7 @@ SocketTopics.bookmark = async function (socket, data) {
|
||||
const postcount = await topics.getTopicField(data.tid, 'postcount');
|
||||
if (data.index > meta.config.bookmarkThreshold && postcount > meta.config.bookmarkThreshold) {
|
||||
const currentIndex = await db.sortedSetScore(`tid:${data.tid}:bookmarks`, socket.uid);
|
||||
if (!currentIndex || data.index > currentIndex) {
|
||||
if (!currentIndex || (data.index > currentIndex && data.index <= postcount) || (currentIndex > postcount)) {
|
||||
await topics.setUserBookmark(data.tid, socket.uid, data.index);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user