Skip to content

Commit 152098b

Browse files
committed
Escape newlines & check for correct return value
1 parent 073acc2 commit 152098b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Context/GivenStepDefinitions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ public function request( \$url, \$headers = array(), \$data = array(), \$options
125125
\$mocked_requests = $mocked_requests;
126126
127127
foreach ( \$mocked_requests as \$pattern => \$response ) {
128-
if ( false !== preg_match( \$pattern, \$url ) ) {
129-
\$pos = strpos( \$response, "\n\n");
128+
if ( 1 === preg_match( \$pattern, \$url ) ) {
129+
\$pos = strpos( \$response, "\\n\\n");
130130
if ( false !== \$pos ) {
131-
\$response = substr( \$response, 0, \$pos ) . "\r\n\r\n" . substr( \$response, \$pos + 2 );
131+
\$response = substr( \$response, 0, \$pos ) . "\\r\\n\\r\\n" . substr( \$response, \$pos + 2 );
132132
}
133133
return \$response;
134134
}
@@ -160,7 +160,7 @@ static function( \$pre, \$parsed_args, \$url ) {
160160
\$mocked_requests = $mocked_requests;
161161
162162
foreach ( \$mocked_requests as \$pattern => \$response ) {
163-
if ( false !== preg_match( \$pattern, \$url ) ) {
163+
if ( 1 === preg_match( \$pattern, \$url ) ) {
164164
\$pos = strpos( \$response, "\n\n");
165165
if ( false !== \$pos ) {
166166
\$response = substr( \$response, 0, \$pos ) . "\r\n\r\n" . substr( \$response, \$pos + 2 );

0 commit comments

Comments
 (0)