File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ private static function isQuotedName(string $name)
139139 */
140140 private static function isValidName (string $ name )
141141 {
142- return Regex::matches ('~\A[a-zA-Z0-9_ .]+\z~ ' , $ name )->success ()->getOrElse (false );
142+ return Regex::matches ('~(*UTF8) \A[\p{Ll}\p{Lu}\p{M}\p{N}_ .]+\z~ ' , $ name )->success ()->getOrElse (false );
143143 }
144144
145145 /**
Original file line number Diff line number Diff line change @@ -335,6 +335,14 @@ public function testEmptyLoading()
335335 self ::assertSame (['EMPTY_VAR ' => null ], $ dotenv ->load ());
336336 }
337337
338+ public function testUnicodeVarNames ()
339+ {
340+ $ dotenv = Dotenv::createImmutable (self ::$ folder , 'unicodevarnames.env ' );
341+ $ dotenv ->load ();
342+ self ::assertSame ('Skybert ' , $ _SERVER ['AlbertÅberg ' ]);
343+ self ::assertSame ('2022-04-01T00:00 ' , $ _SERVER ['ДатаЗакрытияРасчетногоПериода ' ]);
344+ }
345+
338346 public function testDirectConstructor ()
339347 {
340348 $ repository = RepositoryBuilder::createWithDefaultAdapters ()->make ();
Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ public function testNullParse()
2424 $ this ->checkEmptyResult ($ result , 'FOO ' );
2525 }
2626
27+ public function testUnicodeNameParse ()
28+ {
29+ $ result = EntryParser::parse ('FOOƱ=BAZ ' );
30+ $ this ->checkPositiveResult ($ result , 'FOOƱ ' , 'BAZ ' );
31+ }
32+
2733 public function testQuotesParse ()
2834 {
2935 $ result = EntryParser::parse ("FOO= \"BAR \n\"" );
@@ -139,12 +145,6 @@ public function testParseInvalidName()
139145 $ this ->checkErrorResult ($ result , 'Encountered an invalid name at [FOO_ASD!]. ' );
140146 }
141147
142- public function testParseUnicodeName ()
143- {
144- $ result = EntryParser::parse ('FOOƱ=BAZ ' );
145- $ this ->checkErrorResult ($ result , 'Encountered an invalid name at [FOOƱ]. ' );
146- }
147-
148148 public function testParserEscapingDouble ()
149149 {
150150 $ result = EntryParser::parse ('FOO_BAD="iiiiviiiixiiiiviiii \\a" ' );
Original file line number Diff line number Diff line change 1+ AlbertÅberg=Skybert
2+ ДатаЗакрытияРасчетногоПериода='2022-04-01T00:00'
You can’t perform that action at this time.
0 commit comments