@@ -183,6 +183,11 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
183183 return NULL ;
184184 }
185185
186+ /* Should we send the entire path in the request line, default to no. */
187+ if (context && (tmpzval = php_stream_context_get_option (context , "http" , "request_fulluri" )) != NULL ) {
188+ request_fulluri = zend_is_true (tmpzval );
189+ }
190+
186191 use_ssl = resource -> scheme && (ZSTR_LEN (resource -> scheme ) > 4 ) && ZSTR_VAL (resource -> scheme )[4 ] == 's' ;
187192 /* choose default ports */
188193 if (use_ssl && resource -> port == 0 )
@@ -201,6 +206,13 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
201206 }
202207 }
203208
209+ if (request_fulluri && (strchr (path , '\n' ) != NULL || strchr (path , '\r' ) != NULL )) {
210+ php_stream_wrapper_log_error (wrapper , options , "HTTP wrapper full URI path does not allow CR or LF characters" );
211+ php_url_free (resource );
212+ zend_string_release (transport_string );
213+ return NULL ;
214+ }
215+
204216 if (context && (tmpzval = php_stream_context_get_option (context , wrapper -> wops -> label , "timeout" )) != NULL ) {
205217 double d = zval_get_double (tmpzval );
206218#ifndef PHP_WIN32
@@ -381,12 +393,6 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
381393 smart_str_appends (& req_buf , "GET " );
382394 }
383395
384- /* Should we send the entire path in the request line, default to no. */
385- if (!request_fulluri && context &&
386- (tmpzval = php_stream_context_get_option (context , "http" , "request_fulluri" )) != NULL ) {
387- request_fulluri = zend_is_true (tmpzval );
388- }
389-
390396 if (request_fulluri ) {
391397 /* Ask for everything */
392398 smart_str_appends (& req_buf , path );
0 commit comments