Skip to content

Commit

Permalink
Allow line terminators in ICY metadata
Browse files Browse the repository at this point in the history
Issue: #5876
PiperOrigin-RevId: 247935822
  • Loading branch information
ojw28 committed May 15, 2019
1 parent a849f43 commit 0612d9f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Fix NPE when using HLS chunkless preparation
([#5868](https://github.com/google/ExoPlayer/issues/5868)).
* Fix handling of line terminators in SHOUTcast ICY metadata
([#5876](https://github.com/google/ExoPlayer/issues/5876)).
* Offline: Add option to remove all downloads.
* Decoders:
* Prefer codecs that advertise format support over ones that do not, even if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class IcyDecoder implements MetadataDecoder {

private static final String TAG = "IcyDecoder";

private static final Pattern METADATA_ELEMENT = Pattern.compile("(.+?)='(.+?)';");
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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public void decode_quoteInTitle() {
assertThat(streamInfo.url).isEqualTo("test_url");
}

@Test
public void decode_lineTerminatorInTitle() {
IcyDecoder decoder = new IcyDecoder();
Metadata metadata = decoder.decode("StreamTitle='test\r\ntitle';StreamURL='test_url';");

assertThat(metadata.length()).isEqualTo(1);
IcyInfo streamInfo = (IcyInfo) metadata.get(0);
assertThat(streamInfo.title).isEqualTo("test\r\ntitle");
assertThat(streamInfo.url).isEqualTo("test_url");
}

@Test
public void decode_notIcy() {
IcyDecoder decoder = new IcyDecoder();
Expand Down

0 comments on commit 0612d9f

Please sign in to comment.