Allow empty values in ICY metadata

Issue: #5876
PiperOrigin-RevId: 248119726
This commit is contained in:
olly 2019-05-14 13:42:16 +01:00 committed by Oliver Woodman
parent cea3071b33
commit 3ce0d89c56
3 changed files with 13 additions and 2 deletions

View file

@ -4,7 +4,7 @@
* Fix NPE when using HLS chunkless preparation
([#5868](https://github.com/google/ExoPlayer/issues/5868)).
* Fix handling of line terminators in SHOUTcast ICY metadata
* Fix handling of empty values and line terminators in SHOUTcast ICY metadata
([#5876](https://github.com/google/ExoPlayer/issues/5876)).
* Offline: Add option to remove all downloads.
* Add a workaround for a decoder failure on ZTE Axon7 mini devices when playing

View file

@ -31,7 +31,7 @@ public final class IcyDecoder implements MetadataDecoder {
private static final String TAG = "IcyDecoder";
private static final Pattern METADATA_ELEMENT = Pattern.compile("(.+?)='(.+?)';", Pattern.DOTALL);
private static final Pattern METADATA_ELEMENT = Pattern.compile("(.+?)='(.*?)';", Pattern.DOTALL);
private static final String STREAM_KEY_NAME = "streamtitle";
private static final String STREAM_KEY_URL = "streamurl";

View file

@ -48,6 +48,17 @@ public final class IcyDecoderTest {
assertThat(streamInfo.url).isNull();
}
@Test
public void decode_emptyTitle() {
IcyDecoder decoder = new IcyDecoder();
Metadata metadata = decoder.decode("StreamTitle='';StreamURL='test_url';");
assertThat(metadata.length()).isEqualTo(1);
IcyInfo streamInfo = (IcyInfo) metadata.get(0);
assertThat(streamInfo.title).isEmpty();
assertThat(streamInfo.url).isEqualTo("test_url");
}
@Test
public void decode_semiColonInTitle() {
IcyDecoder decoder = new IcyDecoder();