Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 support entry elements with empty strings #3

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/antlr/M3uLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FILE_START: '#EXTM3U';
CHANNEL_START: EXTINF;
NUMBER: '-'? DIGIT+;
SAFE_STRING: SAFE_CHAR+;
QUOTED_STRING: QUOTE (SAFE_CHAR | NUMBER | COLON | EQUALS | SPACES | COMMA)+ QUOTE;
QUOTED_STRING: QUOTE (SAFE_CHAR | NUMBER | COLON | EQUALS | SPACES | COMMA)* QUOTE;
COMMA: ',' -> pushMode(CHANNEL_DESC);
COLON: ':';
EQUALS: '=';
Expand Down
10 changes: 10 additions & 0 deletions src/test/kotlin/ru/grushetsky/m3uparser/M3uParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,14 @@ class M3uParserTest {

assertThat(fileParser.entries().entry_info().size).isEqualTo(2)
}

@Test
fun `entry elements with empty string detected correctly`() {
val entryParser = getParser(getResourceAsString("/entry_with_empty_string.txt")).entry_info()

assertThat(entryParser.enrty_basic_info().entry_name().text).isEqualTo("Channel 1")
assertThat(entryParser.enrty_basic_info().entry_uri().text).isEqualTo("http://1.2.3.4:1234/udp/4.3.2.1:5678")
assertThat(entryParser.parameters().parameter().size).isEqualTo(4)
assertThat(entryParser.length().text).isEqualTo("-1")
}
}
3 changes: 3 additions & 0 deletions src/test/resources/entry_with_empty_string.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#EXTINF:-1 tvg-name="Channel_1" tvg-logo=""
tvg-shift=a0 aspect-ratio=16:9,Channel 1
http://1.2.3.4:1234/udp/4.3.2.1:5678