File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 9090 'id ' => $ data ->id ,
9191 'error ' => array ('message ' => $ e ->getMessage ())
9292 ));
93+ } catch (Error $ e ) {
94+ $ out ->write (array (
95+ 'id ' => $ data ->id ,
96+ 'error ' => array ('message ' => $ e ->getMessage ())
97+ ));
9398 }
9499 } elseif ($ data ->method === 'open ' && \count ($ data ->params ) === 2 && \is_string ($ data ->params [0 ]) && \is_int ($ data ->params [1 ])) {
95100 // open database with two parameters: $filename, $flags
108113 'id ' => $ data ->id ,
109114 'error ' => array ('message ' => $ e ->getMessage ())
110115 ));
116+ } catch (Error $ e ) {
117+ $ out ->write (array (
118+ 'id ' => $ data ->id ,
119+ 'error ' => array ('message ' => $ e ->getMessage ())
120+ ));
111121 }
112122 } elseif ($ data ->method === 'exec ' && $ db !== null && \count ($ data ->params ) === 1 && \is_string ($ data ->params [0 ])) {
113123 // execute statement and suppress PHP warnings
Original file line number Diff line number Diff line change @@ -134,6 +134,29 @@ public function testOpenInvalidPathRejects($flag)
134134 $ loop ->run ();
135135 }
136136
137+ /**
138+ * @dataProvider provideSocketFlags
139+ * @param bool $flag
140+ */
141+ public function testOpenInvalidPathWithNullByteRejects ($ flag )
142+ {
143+ $ loop = \React \EventLoop \Factory::create ();
144+ $ factory = new Factory ($ loop );
145+
146+ $ ref = new \ReflectionProperty ($ factory , 'useSocket ' );
147+ $ ref ->setAccessible (true );
148+ $ ref ->setValue ($ factory , $ flag );
149+
150+ $ promise = $ factory ->open ("test \0.db " );
151+
152+ $ promise ->then (
153+ null ,
154+ $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('RuntimeException ' ))
155+ );
156+
157+ $ loop ->run ();
158+ }
159+
137160 /**
138161 * @dataProvider provideSocketFlags
139162 * @param bool $flag
You can’t perform that action at this time.
0 commit comments