diff --git a/src/eini_lexer.xrl b/src/eini_lexer.xrl index d0b5e50..d66a249 100644 --- a/src/eini_lexer.xrl +++ b/src/eini_lexer.xrl @@ -22,12 +22,13 @@ Definitions. %% Characters for keys K = [a-zA-Z0-9_\-\.]+ -%% Characters for values, printable except =, [ and ] + %% \x3b : $; %% \x3d : $= %% \x5b : $[ %% \x5d : $] -V = [\x21-\x3a\x3c\x3e-\x5a\x5c\x5e-\x7e]+ +V = [^\x3b\x3d\x5b\x5d\x0d\x0a\s\t]+ + %% spaces and breaks S = [\s\t] diff --git a/test/eini_tests.erl b/test/eini_tests.erl index d1df935..b6e5fa5 100644 --- a/test/eini_tests.erl +++ b/test/eini_tests.erl @@ -205,7 +205,7 @@ one_section_title_and_one_prop_test_() -> )), %% Multi blank lines after a prop ?_assertEqual({ok, [ - {title, + {title, [{key1, <<"value1">>}]} ]}, parse( @@ -407,9 +407,9 @@ lex_error_title_test_() -> fun teardown/ 1, [ %% vertical tab in section title - ?_assertMatch({error, {illegal_character, 1, _Reason}}, + ?_assertMatch({error, {syntax_error, 1, _Reason}}, parse("[ti\vtle]")), - ?_assertMatch({error, {illegal_character, 3, _Reason}}, + ?_assertMatch({error, {syntax_error, 3, _Reason}}, parse( "[titleA]\n" "keyA1=valueA1\n" @@ -417,7 +417,7 @@ lex_error_title_test_() -> "keyB1=valueB1\n" )) ]}. - + syntax_error_title_test_() -> %% TODO: Erlang 17 lost the ability to correctly report line numbers from errors. %% Put the numbers back in some day when the fix is released @@ -464,7 +464,7 @@ syntax_error_title_test_() -> parse("[title]\n" " ;comment\n")) ]}. - + syntax_error_property_test_() -> {setup, fun setup/0, @@ -481,7 +481,7 @@ syntax_error_property_test_() -> parse("[title]\n" "key;comment=value\n")) ]}. - + dup_title_test_() -> {setup, fun setup/0, @@ -495,7 +495,7 @@ dup_title_test_() -> "keyB1=valueB1\n" )) ]}. - + dup_key_test_() -> {setup, fun setup/0, @@ -575,3 +575,23 @@ is_section_test_() -> end} ] }. + +unicode_test_() -> + {setup, + fun setup/0, + fun teardown/1, + [ + ?_assertEqual({ok, [ + {title, [{key1, <<"\xD1\x8E\xD0\xBD\xD0\xB8\xD0\xBA\xD0\xBE\xD0\xB4">>}]} + ]}, + parse( + "[title]\n" + "key1= \xD1\x8E\xD0\xBD\xD0\xB8\xD0\xBA\xD0\xBE\xD0\xB4 \n" + )), + ?_assertEqual({ok, [ + {title, [{key1, <<"\xD1\x8E\xD0\xBD\xD0\xB8\xD0\xBA\xD0\xBE\xD0\xB4">>}]} + ]}, + parse( + <<91,116,105,116,108,101,93,10,107,101,121,49,61,209,142,208,189,208,184,208,186,208,190,208,180,10>> + )) + ]}.