Status: protect against infinite context loops

features-override
Alex Gleason 2021-11-23 14:55:40 -06:00
rodzic b9febfc1a3
commit b76bb097f2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -80,7 +80,7 @@ const makeMapStateToProps = () => {
let ancestorsIds = ImmutableOrderedSet();
let id = statusId;
while (id) {
while (id && !ancestorsIds.includes(id)) {
ancestorsIds = ImmutableOrderedSet([id]).union(ancestorsIds);
id = inReplyTos.get(id);
}
@ -99,6 +99,10 @@ const makeMapStateToProps = () => {
const id = ids.shift();
const replies = contextReplies.get(id);
if (descendantsIds.includes(id)) {
break;
}
if (statusId !== id) {
descendantsIds = descendantsIds.union([id]);
}
@ -119,8 +123,11 @@ const makeMapStateToProps = () => {
let descendantsIds = ImmutableOrderedSet();
if (status) {
ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', status.get('id')]) });
descendantsIds = getDescendantsIds(state, { id: status.get('id') });
const statusId = status.get('id');
ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', statusId]) });
descendantsIds = getDescendantsIds(state, { id: statusId });
ancestorsIds = ancestorsIds.delete(statusId).subtract(descendantsIds);
descendantsIds = descendantsIds.delete(statusId).subtract(ancestorsIds);
}
const soapbox = getSoapboxConfig(state);