]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.2'
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 28 Jan 2018 20:53:38 +0000 (21:53 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 28 Jan 2018 20:53:38 +0000 (21:53 +0100)
1  2 
ext/phar/phar_object.c

index 47f57372433bd552343a528a6a7649a13dc9e44c,5a85bf7ad98b71fdfd2d4d075db0a014d1cf3f54..7bba6195747269567fdc9ba4f6368caffeb48c06
@@@ -4346,6 -4346,35 +4346,35 @@@ static int phar_extract_file(zend_bool 
  }
  /* }}} */
  
 -                      if (FAILURE == phar_extract_file(overwrite, entry, pathto, (int)pathto_len, error)) return -1;
+ static int extract_helper(phar_archive_data *archive, zend_string *search, char *pathto, size_t pathto_len, zend_bool overwrite, char **error) { /* {{{ */
+       int extracted = 0;
+       phar_entry_info *entry;
+       if (!search) {
+               /* nothing to match -- extract all files */
+               ZEND_HASH_FOREACH_PTR(&archive->manifest, entry) {
 -                      if (FAILURE == phar_extract_file(overwrite, entry, pathto, (int)pathto_len, error)) return -1;
++                      if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, error)) return -1;
+                       extracted++;
+               } ZEND_HASH_FOREACH_END();
+       } else if ('/' == ZSTR_VAL(search)[ZSTR_LEN(search) - 1]) {
+               /* ends in "/" -- extract all entries having that prefix */
+               ZEND_HASH_FOREACH_PTR(&archive->manifest, entry) {
+                       if (0 != strncmp(ZSTR_VAL(search), entry->filename, ZSTR_LEN(search))) continue;
 -              if (FAILURE == phar_extract_file(overwrite, entry, pathto, (int)pathto_len, error)) return -1;
++                      if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, error)) return -1;
+                       extracted++;
+               } ZEND_HASH_FOREACH_END();
+       } else {
+               /* otherwise, looking for an exact match */
+               entry = zend_hash_find_ptr(&archive->manifest, search);
+               if (NULL == entry) return 0;
++              if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, error)) return -1;
+               return 1;
+       }
+       return extracted;
+ }
+ /* }}} */
  /* {{{ proto bool Phar::extractTo(string pathto[[, mixed files], bool overwrite])
   * Extract one or more file from a phar archive, optionally overwriting existing files
   */