aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorscria1000 <91804886+scria1000@users.noreply.github.com>2023-03-11 04:29:24 +0000
committerGitHub <noreply@github.com>2023-03-11 04:29:24 +0000
commitc4efb14d7cd1201c57f38af0c3d66e886d768d74 (patch)
tree0ed6429e5915a89f8be94d4638f32b79f699c7d2 /app/src/main/java
parent69d2cd8994d8d61ccd4dca6a680e5e5e4737cebc (diff)
downloadinfinity-for-reddit-c4efb14d7cd1201c57f38af0c3d66e886d768d74.tar
infinity-for-reddit-c4efb14d7cd1201c57f38af0c3d66e886d768d74.tar.gz
infinity-for-reddit-c4efb14d7cd1201c57f38af0c3d66e886d768d74.tar.bz2
infinity-for-reddit-c4efb14d7cd1201c57f38af0c3d66e886d768d74.tar.lz
infinity-for-reddit-c4efb14d7cd1201c57f38af0c3d66e886d768d74.tar.xz
infinity-for-reddit-c4efb14d7cd1201c57f38af0c3d66e886d768d74.tar.zst
infinity-for-reddit-c4efb14d7cd1201c57f38af0c3d66e886d768d74.zip
Prevent superscript crash with empty spoiler (#1387)
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptPlugin.java36
1 files changed, 35 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptPlugin.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptPlugin.java
index 796ca870..20a56327 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptPlugin.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/SuperscriptPlugin.java
@@ -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 {
ser_detail_activity.xml?id=d7928436fea370395f389563f7c89e67e6853819&follow=1'>Changing post layout in other activities is available. Show username in card ...Alex Ning11-17/+151 2019-11-11Changing post layout in ViewSubredditDetailActivity is available. Tweak the c...Alex Ning7-15/+55 2019-11-09Update README.mdDocile-Alligator1-2/+3 2019-11-08Compact post layout is available. Fixed WebView cannot be inflated on Android...Alex Ning16-213/+1454 2019-11-05Fixed IllegalStateException in SubredditSelectionActivity. Downgrade material...Alex Ning3-67/+71 2019-10-29Minor UI issue fixed.Alex Ning1-1/+1 2019-10-29Fixed UI issues in posts and comments. Version 1.4.0.Alex Ning14-322/+171 2019-10-29Placing vote buttons on the right for comments is now available.Alex Ning7-24/+210 2019-10-29Make Placing vote buttons on the right an option.Alex Ning42-196/+334