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