@@ -1644,7 +1644,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
1644
1644
{
1645
1645
zval * self = ZEND_THIS ;
1646
1646
char * path = "." ;
1647
- char * remove_path = NULL , * save_remove_path ;
1647
+ char * remove_path = NULL ;
1648
1648
char * add_path = NULL ;
1649
1649
size_t add_path_len , remove_path_len = 0 , path_len = 1 ;
1650
1650
zend_long remove_all_path = 0 ;
@@ -1676,15 +1676,6 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
1676
1676
RETURN_FALSE ;
1677
1677
}
1678
1678
1679
- save_remove_path = remove_path ;
1680
- if (remove_path && remove_path_len > 1 ) {
1681
- size_t real_len = strlen (remove_path );
1682
- if ((real_len > 1 ) && ((remove_path [real_len - 1 ] == '/' ) || (remove_path [real_len - 1 ] == '\\' ))) {
1683
- remove_path = estrndup (remove_path , real_len - 1 );
1684
- remove_path_len -= 1 ;
1685
- }
1686
- }
1687
-
1688
1679
if (type == 1 ) {
1689
1680
found = php_zip_glob (ZSTR_VAL (pattern ), ZSTR_LEN (pattern ), glob_flags , return_value );
1690
1681
} else {
@@ -1707,8 +1698,13 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
1707
1698
file_stripped = ZSTR_VAL (basename );
1708
1699
file_stripped_len = ZSTR_LEN (basename );
1709
1700
} else if (remove_path && strstr (Z_STRVAL_P (zval_file ), remove_path ) != NULL ) {
1710
- file_stripped = Z_STRVAL_P (zval_file ) + remove_path_len ;
1711
- file_stripped_len = Z_STRLEN_P (zval_file ) - remove_path_len ;
1701
+ if (IS_SLASH (Z_STRVAL_P (zval_file )[remove_path_len ])) {
1702
+ file_stripped = Z_STRVAL_P (zval_file ) + remove_path_len + 1 ;
1703
+ file_stripped_len = Z_STRLEN_P (zval_file ) - remove_path_len - 1 ;
1704
+ } else {
1705
+ file_stripped = Z_STRVAL_P (zval_file ) + remove_path_len ;
1706
+ file_stripped_len = Z_STRLEN_P (zval_file ) - remove_path_len ;
1707
+ }
1712
1708
} else {
1713
1709
file_stripped = Z_STRVAL_P (zval_file );
1714
1710
file_stripped_len = Z_STRLEN_P (zval_file );
@@ -1741,9 +1737,6 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
1741
1737
}
1742
1738
}
1743
1739
}
1744
- if (remove_path != save_remove_path ) {
1745
- efree (remove_path );
1746
- }
1747
1740
}
1748
1741
/* }}} */
1749
1742
0 commit comments