mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-29 02:54:44 +01:00
Prevent superscript crash with empty spoiler (#1387)
This commit is contained in:
parent
69d2cd8994
commit
c4efb14d7c
@ -142,6 +142,36 @@ public class SuperscriptPlugin extends AbstractMarkwonPlugin {
|
||||
if (notEmptyLink((Link) next)) {
|
||||
return true;
|
||||
}
|
||||
} else if (next instanceof SpoilerNode) {
|
||||
if (notEmptySpoilerNode((SpoilerNode) next)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
next = next.getNext();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean notEmptySpoilerNode(SpoilerNode spoilerNode) {
|
||||
Node next = spoilerNode.getFirstChild();
|
||||
while (next != null) {
|
||||
if (next instanceof Text) {
|
||||
return true;
|
||||
} else if (next instanceof Superscript) {
|
||||
if (notEmptySuperscript((Superscript) next)) {
|
||||
return true;
|
||||
}
|
||||
} else if (next instanceof Link) {
|
||||
if (notEmptyLink((Link) next)) {
|
||||
return true;
|
||||
}
|
||||
} else if (next instanceof SpoilerNode) {
|
||||
if (notEmptySpoilerNode((SpoilerNode) next)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@ -154,7 +184,7 @@ public class SuperscriptPlugin extends AbstractMarkwonPlugin {
|
||||
private boolean notEmptySuperscript(Superscript superscript) {
|
||||
Node next;
|
||||
if (superscript.isBracketed()) {
|
||||
next = superscript.getFirstChild();
|
||||
next = superscript.getFirstChild();
|
||||
} else {
|
||||
next = superscript.getNext();
|
||||
}
|
||||
@ -164,6 +194,10 @@ public class SuperscriptPlugin extends AbstractMarkwonPlugin {
|
||||
if (notEmptyLink((Link) next)) {
|
||||
return true;
|
||||
}
|
||||
} else if (next instanceof SpoilerNode) {
|
||||
if (notEmptySpoilerNode((SpoilerNode) next)) {
|
||||
return true;
|
||||
}
|
||||
} else if (!(next instanceof Superscript)) {
|
||||
return true;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user