mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-07 14:03:31 +01:00
Fixed feeds with newlines in their image tags
This commit is contained in:
parent
92033f8373
commit
bb15f25832
@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.syndication.namespace;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.syndication.util.SyndStringUtils;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
@ -98,7 +99,8 @@ public class NSRSS20 extends Namespace {
|
|||||||
}
|
}
|
||||||
state.setCurrentItem(null);
|
state.setCurrentItem(null);
|
||||||
} else if (state.getTagstack().size() >= 2 && state.getContentBuf() != null) {
|
} else if (state.getTagstack().size() >= 2 && state.getContentBuf() != null) {
|
||||||
String content = state.getContentBuf().toString();
|
String contentRaw = state.getContentBuf().toString();
|
||||||
|
String content = SyndStringUtils.trimAllWhitespace(contentRaw);
|
||||||
SyndElement topElement = state.getTagstack().peek();
|
SyndElement topElement = state.getTagstack().peek();
|
||||||
String top = topElement.getName();
|
String top = topElement.getName();
|
||||||
SyndElement secondElement = state.getSecondTag();
|
SyndElement secondElement = state.getSecondTag();
|
||||||
@ -110,15 +112,14 @@ public class NSRSS20 extends Namespace {
|
|||||||
if (GUID.equals(top) && ITEM.equals(second)) {
|
if (GUID.equals(top) && ITEM.equals(second)) {
|
||||||
// some feed creators include an empty or non-standard guid-element in their feed,
|
// some feed creators include an empty or non-standard guid-element in their feed,
|
||||||
// which should be ignored
|
// which should be ignored
|
||||||
if (!TextUtils.isEmpty(content) && state.getCurrentItem() != null) {
|
if (!TextUtils.isEmpty(contentRaw) && state.getCurrentItem() != null) {
|
||||||
state.getCurrentItem().setItemIdentifier(content);
|
state.getCurrentItem().setItemIdentifier(contentRaw);
|
||||||
}
|
}
|
||||||
} else if (TITLE.equals(top)) {
|
} else if (TITLE.equals(top)) {
|
||||||
String title = content.trim();
|
|
||||||
if (ITEM.equals(second) && state.getCurrentItem() != null) {
|
if (ITEM.equals(second) && state.getCurrentItem() != null) {
|
||||||
state.getCurrentItem().setTitle(title);
|
state.getCurrentItem().setTitle(content);
|
||||||
} else if (CHANNEL.equals(second) && state.getFeed() != null) {
|
} else if (CHANNEL.equals(second) && state.getFeed() != null) {
|
||||||
state.getFeed().setTitle(title);
|
state.getFeed().setTitle(content);
|
||||||
}
|
}
|
||||||
} else if (LINK.equals(top)) {
|
} else if (LINK.equals(top)) {
|
||||||
if (CHANNEL.equals(second) && state.getFeed() != null) {
|
if (CHANNEL.equals(second) && state.getFeed() != null) {
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package de.danoeh.antennapod.core.syndication.util;
|
||||||
|
|
||||||
|
public class SyndStringUtils {
|
||||||
|
private SyndStringUtils() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims all whitespace from beginning and ending of a String. {{@link String#trim()}} only trims spaces.
|
||||||
|
*/
|
||||||
|
public static String trimAllWhitespace(String string) {
|
||||||
|
return string.replaceAll("(^\\s*)|(\\s*$)", "");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user