Gracefully handle bad ID3 chapter URLs

This commit is contained in:
Joe Stein 2019-07-01 13:40:46 +02:00
parent abcd6f772e
commit f047c23c09
1 changed files with 11 additions and 9 deletions

View File

@ -1,6 +1,10 @@
package de.danoeh.antennapod.core.util.id3reader; package de.danoeh.antennapod.core.util.id3reader;
import android.util.Log; import android.util.Log;
import de.danoeh.antennapod.core.feed.Chapter;
import de.danoeh.antennapod.core.feed.ID3Chapter;
import de.danoeh.antennapod.core.util.id3reader.model.FrameHeader;
import de.danoeh.antennapod.core.util.id3reader.model.TagHeader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -8,11 +12,6 @@ import java.net.URLDecoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import de.danoeh.antennapod.core.feed.Chapter;
import de.danoeh.antennapod.core.feed.ID3Chapter;
import de.danoeh.antennapod.core.util.id3reader.model.FrameHeader;
import de.danoeh.antennapod.core.util.id3reader.model.TagHeader;
public class ChapterReader extends ID3Reader { public class ChapterReader extends ID3Reader {
private static final String TAG = "ID3ChapterReader"; private static final String TAG = "ID3ChapterReader";
@ -69,11 +68,14 @@ public class ChapterReader extends ID3Reader {
int descriptionLength = readString(null, input, header.getSize()); int descriptionLength = readString(null, input, header.getSize());
StringBuilder link = new StringBuilder(); StringBuilder link = new StringBuilder();
readISOString(link, input, header.getSize() - descriptionLength); readISOString(link, input, header.getSize() - descriptionLength);
String decodedLink = URLDecoder.decode(link.toString(), "UTF-8"); try {
String decodedLink = URLDecoder.decode(link.toString(), "UTF-8");
currentChapter.setLink(decodedLink);
Log.d(TAG, "Found link: " + currentChapter.getLink());
} catch (IllegalArgumentException _iae) {
Log.w(TAG, "Bad URL found in ID3 data");
}
currentChapter.setLink(decodedLink);
Log.d(TAG, "Found link: " + currentChapter.getLink());
return ID3Reader.ACTION_DONT_SKIP; return ID3Reader.ACTION_DONT_SKIP;
} }
break; break;