summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh/antennapod/activity
diff options
context:
space:
mode:
authorMartin Fietz <Martin.Fietz@gmail.com>2016-10-03 12:26:47 +0200
committerMartin Fietz <Martin.Fietz@gmail.com>2016-11-01 20:13:48 +0100
commit00f99fb2026422265cc8622a285ca4f9a8cc9056 (patch)
tree9d66f99431535010ae6c76cd551890aecadc616e /app/src/main/java/de/danoeh/antennapod/activity
parentc2a7adc6c4a1600749437de624391aff7fbfbff3 (diff)
downloadAntennaPod-00f99fb2026422265cc8622a285ca4f9a8cc9056.zip
Sanitize HTML from Atom feed descriptions/subtitles
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/activity')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java21
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java19
2 files changed, 30 insertions, 10 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java
index 31b405329..3ccb94d97 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java
@@ -28,6 +28,10 @@ import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.joanzapata.iconify.Iconify;
+import org.apache.commons.lang3.StringUtils;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
@@ -157,9 +161,20 @@ public class FeedInfoActivity extends AppCompatActivity {
.into(imgvCover);
txtvTitle.setText(feed.getTitle());
+
String description = feed.getDescription();
- txtvDescription.setText((description != null) ? description.trim() : "");
- if (!TextUtils.isEmpty(feed.getAuthor())) {
+ if(description != null) {
+ if(Feed.TYPE_ATOM1.equals(feed.getType())) {
+ HtmlToPlainText formatter = new HtmlToPlainText();
+ Document feedDescription = Jsoup.parse(feed.getDescription());
+ description = StringUtils.trim(formatter.getPlainText(feedDescription));
+ }
+ } else {
+ description = "";
+ }
+ txtvDescription.setText(description);
+
+ if (feed.getAuthor() != null) {
txtvAuthor.setText(feed.getAuthor());
} else {
lblAuthor.setVisibility(View.GONE);
@@ -379,7 +394,7 @@ public class FeedInfoActivity extends AppCompatActivity {
private final Feed feed;
private final boolean autoDownload;
- public ApplyToEpisodesDialog(Context context, Feed feed, boolean autoDownload) {
+ ApplyToEpisodesDialog(Context context, Feed feed, boolean autoDownload) {
super(context, R.string.auto_download_apply_to_items_title,
R.string.auto_download_apply_to_items_message);
this.feed = feed;
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
index a40877832..592be3ec6 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java
@@ -116,7 +116,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
@Override
public void update(EventDistributor eventDistributor, Integer arg) {
if ((arg & EventDistributor.FEED_LIST_UPDATE) != 0) {
- updater = Observable.fromCallable(() -> DBReader.getFeedList())
+ updater = Observable.fromCallable(DBReader::getFeedList)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
@@ -284,7 +284,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
})
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
- .subscribe(status -> checkDownloadResult(status),
+ .subscribe(this::checkDownloadResult,
error -> Log.e(TAG, Log.getStackTraceString(error)));
}
@@ -360,14 +360,19 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
* This method is executed on a background thread
*/
private void beforeShowFeedInformation(Feed feed) {
- // remove HTML tags from descriptions
+ final HtmlToPlainText formatter = new HtmlToPlainText();
+ if(Feed.TYPE_ATOM1.equals(feed.getType())) {
+ // remove HTML tags from descriptions
+ Log.d(TAG, "Removing HTML from feed description");
+ Document feedDescription = Jsoup.parse(feed.getDescription());
+ feed.setDescription(StringUtils.trim(formatter.getPlainText(feedDescription)));
+ }
Log.d(TAG, "Removing HTML from shownotes");
if (feed.getItems() != null) {
- HtmlToPlainText formatter = new HtmlToPlainText();
for (FeedItem item : feed.getItems()) {
if (item.getDescription() != null) {
- Document description = Jsoup.parse(item.getDescription());
- item.setDescription(StringUtils.trim(formatter.getPlainText(description)));
+ Document itemDescription = Jsoup.parse(item.getDescription());
+ item.setDescription(StringUtils.trim(formatter.getPlainText(itemDescription)));
}
}
}
@@ -589,7 +594,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
private String feedUrl;
- public FeedViewAuthenticationDialog(Context context, int titleRes, String feedUrl) {
+ FeedViewAuthenticationDialog(Context context, int titleRes, String feedUrl) {
super(context, titleRes, true, false, null, null);
this.feedUrl = feedUrl;
}