kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Status: protect against infinite context loops
rodzic
b9febfc1a3
commit
b76bb097f2
|
@ -80,7 +80,7 @@ const makeMapStateToProps = () => {
|
||||||
let ancestorsIds = ImmutableOrderedSet();
|
let ancestorsIds = ImmutableOrderedSet();
|
||||||
let id = statusId;
|
let id = statusId;
|
||||||
|
|
||||||
while (id) {
|
while (id && !ancestorsIds.includes(id)) {
|
||||||
ancestorsIds = ImmutableOrderedSet([id]).union(ancestorsIds);
|
ancestorsIds = ImmutableOrderedSet([id]).union(ancestorsIds);
|
||||||
id = inReplyTos.get(id);
|
id = inReplyTos.get(id);
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,10 @@ const makeMapStateToProps = () => {
|
||||||
const id = ids.shift();
|
const id = ids.shift();
|
||||||
const replies = contextReplies.get(id);
|
const replies = contextReplies.get(id);
|
||||||
|
|
||||||
|
if (descendantsIds.includes(id)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (statusId !== id) {
|
if (statusId !== id) {
|
||||||
descendantsIds = descendantsIds.union([id]);
|
descendantsIds = descendantsIds.union([id]);
|
||||||
}
|
}
|
||||||
|
@ -119,8 +123,11 @@ const makeMapStateToProps = () => {
|
||||||
let descendantsIds = ImmutableOrderedSet();
|
let descendantsIds = ImmutableOrderedSet();
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
ancestorsIds = getAncestorsIds(state, { id: state.getIn(['contexts', 'inReplyTos', status.get('id')]) });
|
const statusId = status.get('id');
|
||||||
descendantsIds = getDescendantsIds(state, { id: 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);
|
const soapbox = getSoapboxConfig(state);
|
||||||
|
|
Ładowanie…
Reference in New Issue