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)
42
42
private static function multilineProcess ($ multiline , $ line , array $ buffer )
43
43
{
44
44
// check if $line can be multiline variable
45
- if (self ::looksLikeMultilineStart ($ line )) {
45
+ if ($ started = self ::looksLikeMultilineStart ($ line )) {
46
46
$ multiline = true ;
47
47
}
48
48
49
49
if ($ multiline ) {
50
50
array_push ($ buffer , $ line );
51
51
52
- if (self ::looksLikeMultilineStop ($ line )) {
52
+ if (self ::looksLikeMultilineStop ($ line, $ started )) {
53
53
$ multiline = false ;
54
54
$ line = implode ("\n" , $ buffer );
55
55
$ buffer = [];
@@ -72,29 +72,32 @@ private static function looksLikeMultilineStart($line)
72
72
return false ;
73
73
}
74
74
75
- return self ::looksLikeMultilineStop ($ line ) === false ;
75
+ return self ::looksLikeMultilineStop ($ line, true ) === false ;
76
76
}
77
77
78
78
/**
79
79
* Determine if the given line can be the start of a multiline variable.
80
80
*
81
81
* @param string $line
82
+ * @param bool $started
82
83
*
83
84
* @return bool
84
85
*/
85
- private static function looksLikeMultilineStop ($ line )
86
+ private static function looksLikeMultilineStop ($ line, $ started )
86
87
{
87
88
if ($ line === '" ' ) {
88
89
return true ;
89
90
}
90
91
92
+ $ seen = $ started ? 0 : 1 ;
93
+
91
94
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 ++ ;
94
97
}
95
98
}
96
99
97
- return false ;
100
+ return $ seen > 1 ;
98
101
}
99
102
100
103
/**
Original file line number Diff line number Diff line change @@ -288,6 +288,8 @@ public function testMutlilineLoading()
288
288
$ dotenv = Dotenv::create ($ this ->fixturesFolder , 'multiline.env ' );
289
289
$ dotenv ->load ();
290
290
$ 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 ' ));
291
293
}
292
294
293
295
public function testDotenvAssertions ()
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ public function testProcessQuotes()
30
30
31
31
$ expected = [
32
32
"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= \'' ,
33
35
];
34
36
35
37
$ this ->assertSame ($ expected , Lines::process (preg_split ("/( \r\n| \n| \r)/ " , $ content )));
Original file line number Diff line number Diff line change 1
1
TEST = "test
2
2
test\"test\"
3
3
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