3838#endif
3939
4040#include "php_standard.h"
41- #include "ext/uri/php_uri.h"
4241
4342#include <sys/types.h>
4443#ifdef HAVE_SYS_SOCKET_H
@@ -122,24 +121,6 @@ static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream *
122121}
123122/* }}} */
124123
125- static uri_handler_t * ftp_get_uri_handler (php_stream_context * context )
126- {
127- if (context == NULL ) {
128- return php_uri_get_handler (NULL );
129- }
130-
131- zval * uri_handler_name = php_stream_context_get_option (context , "ftp" , "uri_parser_class" );
132- if (uri_handler_name == NULL ) {
133- return php_uri_get_handler (NULL );
134- }
135-
136- if (Z_TYPE_P (uri_handler_name ) != IS_STRING ) {
137- return NULL ;
138- }
139-
140- return php_uri_get_handler (Z_STR_P (uri_handler_name ));
141- }
142-
143124/* {{{ php_ftp_fopen_connect */
144125static php_stream * php_ftp_fopen_connect (php_stream_wrapper * wrapper , const char * path , const char * mode , int options ,
145126 zend_string * * opened_path , php_stream_context * context , php_stream * * preuseid ,
@@ -152,14 +133,12 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
152133 char * transport ;
153134 int transport_len ;
154135
155- uri_handler_t * uri_handler = ftp_get_uri_handler ( context );
136+ uri_handler_t * uri_handler = php_stream_context_get_uri_handler ( "ftp" , context );
156137 if (uri_handler == NULL ) {
157138 return NULL ;
158139 }
159140
160- zend_string * tmp_uri = zend_string_init (path , strlen (path ), false);
161- resource = php_uri_parse_to_struct (uri_handler , tmp_uri , URI_COMPONENT_READ_RAW , true);
162- zend_string_release_ex (tmp_uri , false);
141+ resource = php_uri_parse_to_struct (uri_handler , path , strlen (path ), URI_COMPONENT_READ_RAW , true);
163142 if (resource == NULL || resource -> path == NULL ) {
164143 if (resource && presource ) {
165144 * presource = resource ;
@@ -974,21 +953,17 @@ static int php_stream_ftp_rename(php_stream_wrapper *wrapper, const char *url_fr
974953 int result ;
975954 char tmp_line [512 ];
976955
977- uri_handler_t * uri_handler = ftp_get_uri_handler ( context );
956+ uri_handler_t * uri_handler = php_stream_context_get_uri_handler ( "ftp" , context );
978957 if (uri_handler == NULL ) {
979958 return 0 ;
980959 }
981960
982- zend_string * tmp_uri = zend_string_init (url_from , strlen (url_from ), false);
983- resource_from = php_uri_parse_to_struct (uri_handler , tmp_uri , URI_COMPONENT_READ_RAW , true);
984- zend_string_release_ex (tmp_uri , false);
961+ resource_from = php_uri_parse_to_struct (uri_handler , url_from , strlen (url_from ), URI_COMPONENT_READ_RAW , true);
985962 if (!resource_from ) {
986963 return 0 ;
987964 }
988965
989- tmp_uri = zend_string_init (url_to , strlen (url_to ), false);
990- resource_to = php_uri_parse_to_struct (uri_handler , tmp_uri , URI_COMPONENT_READ_RAW , true);
991- zend_string_release_ex (tmp_uri , 1 );
966+ resource_to = php_uri_parse_to_struct (uri_handler , url_to , strlen (url_to ), URI_COMPONENT_READ_RAW , true);
992967 if (!resource_to ) {
993968 goto rename_errexit ;
994969 }
0 commit comments