mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-14 20:27:12 +01:00
Fix NullPointerException in Utils.parseInlineEmotes.
This commit is contained in:
parent
05e9b8b36e
commit
3fa86984dc
@ -190,30 +190,32 @@ public final class Utils {
|
|||||||
|
|
||||||
public static String parseInlineEmotes(String markdown, JSONObject mediaMetadataObject) throws JSONException {
|
public static String parseInlineEmotes(String markdown, JSONObject mediaMetadataObject) throws JSONException {
|
||||||
JSONArray mediaMetadataNames = mediaMetadataObject.names();
|
JSONArray mediaMetadataNames = mediaMetadataObject.names();
|
||||||
for (int i = 0; i < mediaMetadataNames.length(); i++) {
|
if (mediaMetadataNames != null) {
|
||||||
if (!mediaMetadataNames.isNull(i)) {
|
for (int i = 0; i < mediaMetadataNames.length(); i++) {
|
||||||
String mediaMetadataKey = mediaMetadataNames.getString(i);
|
if (!mediaMetadataNames.isNull(i)) {
|
||||||
if (mediaMetadataObject.isNull(mediaMetadataKey)) {
|
String mediaMetadataKey = mediaMetadataNames.getString(i);
|
||||||
continue;
|
if (mediaMetadataObject.isNull(mediaMetadataKey)) {
|
||||||
}
|
continue;
|
||||||
JSONObject item = mediaMetadataObject.getJSONObject(mediaMetadataKey);
|
}
|
||||||
if (item.isNull(JSONUtils.STATUS_KEY)
|
JSONObject item = mediaMetadataObject.getJSONObject(mediaMetadataKey);
|
||||||
|| !item.getString(JSONUtils.STATUS_KEY).equals("valid")
|
if (item.isNull(JSONUtils.STATUS_KEY)
|
||||||
|| item.isNull(JSONUtils.ID_KEY)
|
|| !item.getString(JSONUtils.STATUS_KEY).equals("valid")
|
||||||
|| item.isNull(JSONUtils.T_KEY)
|
|| item.isNull(JSONUtils.ID_KEY)
|
||||||
|| item.isNull(JSONUtils.S_KEY)) {
|
|| item.isNull(JSONUtils.T_KEY)
|
||||||
continue;
|
|| item.isNull(JSONUtils.S_KEY)) {
|
||||||
}
|
continue;
|
||||||
String emote_type = item.getString(JSONUtils.T_KEY);
|
}
|
||||||
String emote_id = item.getString(JSONUtils.ID_KEY);
|
String emote_type = item.getString(JSONUtils.T_KEY);
|
||||||
|
String emote_id = item.getString(JSONUtils.ID_KEY);
|
||||||
|
|
||||||
JSONObject s_key = item.getJSONObject(JSONUtils.S_KEY);
|
JSONObject s_key = item.getJSONObject(JSONUtils.S_KEY);
|
||||||
if (s_key.isNull(JSONUtils.U_KEY)) {
|
if (s_key.isNull(JSONUtils.U_KEY)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String emote_url = s_key.getString(JSONUtils.U_KEY);
|
String emote_url = s_key.getString(JSONUtils.U_KEY);
|
||||||
|
|
||||||
markdown = markdown.replace("![img](" + emote_id + ")", "[" + emote_type + "](" + emote_url + ") ");
|
markdown = markdown.replace("![img](" + emote_id + ")", "[" + emote_type + "](" + emote_url + ") ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return markdown;
|
return markdown;
|
||||||
|
Loading…
Reference in New Issue
Block a user