diff --git a/src/main/antlr/M3uLexer.g4 b/src/main/antlr/M3uLexer.g4 index 9ffe189..6ca5181 100644 --- a/src/main/antlr/M3uLexer.g4 +++ b/src/main/antlr/M3uLexer.g4 @@ -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: '='; diff --git a/src/test/kotlin/ru/grushetsky/m3uparser/M3uParserTest.kt b/src/test/kotlin/ru/grushetsky/m3uparser/M3uParserTest.kt index 28bed4a..dce0008 100644 --- a/src/test/kotlin/ru/grushetsky/m3uparser/M3uParserTest.kt +++ b/src/test/kotlin/ru/grushetsky/m3uparser/M3uParserTest.kt @@ -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") + } } \ No newline at end of file diff --git a/src/test/resources/entry_with_empty_string.txt b/src/test/resources/entry_with_empty_string.txt new file mode 100644 index 0000000..688d4e6 --- /dev/null +++ b/src/test/resources/entry_with_empty_string.txt @@ -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 \ No newline at end of file