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 @@ -42,14 +42,14 @@ public static function process(array $lines)
4242 private static function multilineProcess ($ multiline , $ line , array $ buffer )
4343 {
4444 // check if $line can be multiline variable
45- if (self ::looksLikeMultilineStart ($ line )) {
45+ if ($ started = self ::looksLikeMultilineStart ($ line )) {
4646 $ multiline = true ;
4747 }
4848
4949 if ($ multiline ) {
5050 array_push ($ buffer , $ line );
5151
52- if (self ::looksLikeMultilineStop ($ line )) {
52+ if (self ::looksLikeMultilineStop ($ line, $ started )) {
5353 $ multiline = false ;
5454 $ line = implode ("\n" , $ buffer );
5555 $ buffer = [];
@@ -72,29 +72,32 @@ private static function looksLikeMultilineStart($line)
7272 return false ;
7373 }
7474
75- return self ::looksLikeMultilineStop ($ line ) === false ;
75+ return self ::looksLikeMultilineStop ($ line, true ) === false ;
7676 }
7777
7878 /**
7979 * Determine if the given line can be the start of a multiline variable.
8080 *
8181 * @param string $line
82+ * @param bool $started
8283 *
8384 * @return bool
8485 */
85- private static function looksLikeMultilineStop ($ line )
86+ private static function looksLikeMultilineStop ($ line, $ started )
8687 {
8788 if ($ line === '" ' ) {
8889 return true ;
8990 }
9091
92+ $ seen = $ started ? 0 : 1 ;
93+
9194 foreach (self ::getCharPairs (str_replace ('\\\\' , '' , $ line )) as $ pair ) {
92- if ($ pair [0 ] !== '\\' && $ pair [0 ] !== ' = ' && $ pair [ 1 ] === '" ' ) {
93- return true ;
95+ if ($ pair [0 ] !== '\\' && $ pair [1 ] === '" ' ) {
96+ $ seen ++ ;
9497 }
9598 }
9699
97- return false ;
100+ return $ seen > 1 ;
98101 }
99102
100103 /**
Original file line number Diff line number Diff line change @@ -288,6 +288,8 @@ public function testMutlilineLoading()
288288 $ dotenv = Dotenv::create ($ this ->fixturesFolder , 'multiline.env ' );
289289 $ dotenv ->load ();
290290 $ this ->assertSame ("test \n test \"test \"\n test " , getenv ('TEST ' ));
291+ $ this ->assertSame ('https://vision.googleapis.com/v1/images:annotate?key= ' , getenv ('TEST_EQD ' ));
292+ $ this ->assertSame ('https://vision.googleapis.com/v1/images:annotate?key= ' , getenv ('TEST_EQS ' ));
291293 }
292294
293295 public function testDotenvAssertions ()
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ public function testProcessQuotes()
3030
3131 $ expected = [
3232 "TEST= \"test \n test \\\"test \\\"\n test \"" ,
33+ 'TEST_EQD="https://vision.googleapis.com/v1/images:annotate?key=" ' ,
34+ 'TEST_EQS= \'https://vision.googleapis.com/v1/images:annotate?key= \'' ,
3335 ];
3436
3537 $ this ->assertSame ($ expected , Lines::process (preg_split ("/( \r\n| \n| \r)/ " , $ content )));
Original file line number Diff line number Diff line change 11TEST = " test
22 test\" test\"
33 test"
4+
5+ TEST_EQD = " https://vision.googleapis.com/v1/images:annotate?key="
6+ TEST_EQS = ' https://vision.googleapis.com/v1/images:annotate?key='
You can’t perform that action at this time.
0 commit comments