@@ -741,7 +741,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
741
741
}
742
742
/* }}} */
743
743
744
- static int phar_wrapper_rename (php_stream_wrapper * wrapper , const char * url_from , const char * url_to , int options , php_stream_context * context ) /* {{{ */
744
+ static bool phar_wrapper_rename (php_stream_wrapper * wrapper , const zend_string * url_from , const zend_string * url_to , int options , php_stream_context * context ) /* {{{ */
745
745
{
746
746
php_url * resource_from , * resource_to ;
747
747
char * error ;
@@ -753,8 +753,8 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
753
753
754
754
error = NULL ;
755
755
756
- if ((resource_from = phar_parse_url (wrapper , url_from , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
757
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , url_from , url_to , url_from );
756
+ if ((resource_from = phar_parse_url (wrapper , ZSTR_VAL ( url_from ) , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
757
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_from ) );
758
758
return 0 ;
759
759
}
760
760
if (SUCCESS != phar_get_archive (& pfrom , ZSTR_VAL (resource_from -> host ), ZSTR_LEN (resource_from -> host ), NULL , 0 , & error )) {
@@ -769,9 +769,9 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
769
769
return 0 ;
770
770
}
771
771
772
- if ((resource_to = phar_parse_url (wrapper , url_to , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
772
+ if ((resource_to = phar_parse_url (wrapper , ZSTR_VAL ( url_to ) , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
773
773
php_url_free (resource_from );
774
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , url_from , url_to , url_to );
774
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_to ) );
775
775
return 0 ;
776
776
}
777
777
if (SUCCESS != phar_get_archive (& pto , ZSTR_VAL (resource_to -> host ), ZSTR_LEN (resource_to -> host ), NULL , 0 , & error )) {
@@ -790,36 +790,36 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
790
790
if (!zend_string_equals (resource_from -> host , resource_to -> host )) {
791
791
php_url_free (resource_from );
792
792
php_url_free (resource_to );
793
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive" , url_from , url_to );
793
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
794
794
return 0 ;
795
795
}
796
796
797
797
/* we must have at the very least phar://alias.phar/internalfile.php */
798
798
if (!resource_from -> scheme || !resource_from -> host || !resource_from -> path ) {
799
799
php_url_free (resource_from );
800
800
php_url_free (resource_to );
801
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , url_from , url_to , url_from );
801
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_from ) );
802
802
return 0 ;
803
803
}
804
804
805
805
if (!resource_to -> scheme || !resource_to -> host || !resource_to -> path ) {
806
806
php_url_free (resource_from );
807
807
php_url_free (resource_to );
808
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , url_from , url_to , url_to );
808
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_to ) );
809
809
return 0 ;
810
810
}
811
811
812
812
if (!zend_string_equals_literal_ci (resource_from -> scheme , "phar" )) {
813
813
php_url_free (resource_from );
814
814
php_url_free (resource_to );
815
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , url_from , url_to , url_from );
815
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_from ) );
816
816
return 0 ;
817
817
}
818
818
819
819
if (!zend_string_equals_literal_ci (resource_to -> scheme , "phar" )) {
820
820
php_url_free (resource_from );
821
821
php_url_free (resource_to );
822
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , url_from , url_to , url_to );
822
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_to ) );
823
823
return 0 ;
824
824
}
825
825
@@ -828,15 +828,15 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
828
828
if (SUCCESS != phar_get_archive (& phar , ZSTR_VAL (resource_from -> host ), host_len , NULL , 0 , & error )) {
829
829
php_url_free (resource_from );
830
830
php_url_free (resource_to );
831
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
831
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) , error );
832
832
efree (error );
833
833
return 0 ;
834
834
}
835
835
836
836
if (phar -> is_persistent && FAILURE == phar_copy_on_write (& phar )) {
837
837
php_url_free (resource_from );
838
838
php_url_free (resource_to );
839
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": could not make cached phar writeable" , url_from , url_to );
839
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": could not make cached phar writeable" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
840
840
return 0 ;
841
841
}
842
842
@@ -847,7 +847,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
847
847
if (entry -> is_deleted ) {
848
848
php_url_free (resource_from );
849
849
php_url_free (resource_to );
850
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source has been deleted" , url_from , url_to );
850
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source has been deleted" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
851
851
return 0 ;
852
852
}
853
853
/* transfer all data over to the new entry */
@@ -867,7 +867,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
867
867
if (FAILURE == phar_copy_entry_fp (source , entry , & error )) {
868
868
php_url_free (resource_from );
869
869
php_url_free (resource_to );
870
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
870
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) , error );
871
871
efree (error );
872
872
zend_hash_str_del (& (phar -> manifest ), entry -> filename , strlen (entry -> filename ));
873
873
return 0 ;
@@ -882,7 +882,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
882
882
/* file does not exist */
883
883
php_url_free (resource_from );
884
884
php_url_free (resource_to );
885
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does not exist" , url_from , url_to );
885
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does not exist" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
886
886
return 0 ;
887
887
888
888
}
@@ -963,7 +963,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
963
963
if (error ) {
964
964
php_url_free (resource_from );
965
965
php_url_free (resource_to );
966
- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
966
+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) , error );
967
967
efree (error );
968
968
return 0 ;
969
969
}
0 commit comments