default services conflit ?

This commit is contained in:
armansansd
2022-04-27 11:30:43 +02:00
parent 28190a5749
commit 8bb1064a3b
8132 changed files with 900138 additions and 426 deletions

View File

@@ -0,0 +1,2 @@
github: [mrook]
patreon: michielrook

View File

@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "composer" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

View File

@@ -0,0 +1,40 @@
on:
push:
branches:
- master
pull_request:
jobs:
test:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
dependencies: [ 'locked' ]
name: PHP ${{ matrix.php }} on ${{ matrix.operating-system }} with ${{ matrix.dependencies }} dependencies
steps:
- uses: actions/checkout@v2
name: Checkout repository
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.dependencies }}
- name: Install PEAR
run: |
sudo apt-get install php-pear
- name: Run tests
run: |
sudo pear install -f package.xml
pear version
pear run-tests -qr tests/ || { cat run-tests.log; for i in `find tests/ -name '*.out'`; do echo "$i"; cat "$i"; done; exit 1; }

15
old.vendor/pear/archive_tar/.gitignore vendored Normal file
View File

@@ -0,0 +1,15 @@
# composer related
composer.lock
composer.phar
vendor
# IDE
.idea
# eclipse
.buildpath
.project
.settings
# pear
.tarballs
*.tgz
# phpunit
build

View File

@@ -0,0 +1,29 @@
sudo: false
language: php
matrix:
fast_finish: true
allow_failures:
- php: nightly
include:
- php: 5.2
dist: precise
- php: 5.3
dist: precise
- php: 5.4
dist: trusty
- php: 5.5
dist: trusty
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
- php: nightly
install:
# - pear upgrade --force --alldeps pear/pear
- pear install -f package.xml
script:
- pear version
- pear run-tests -qr tests/
- for i in `find tests/ -name '*.out'`; do echo "$i"; cat "$i"; done

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
Archive_Tar
==========
![.github/workflows/build.yml](https://github.com/pear/Archive_Tar/workflows/.github/workflows/build.yml/badge.svg)
This package provides handling of tar files in PHP.
It supports creating, listing, extracting and adding to tar files.
Gzip support is available if PHP has the zlib extension built-in or
loaded. Bz2 compression is also supported with the bz2 extension loaded.
Also Lzma2 compressed archives are supported with xz extension.
This package is hosted at http://pear.php.net/package/Archive_Tar
Please report all new issues via the PEAR bug tracker.
Pull requests are welcome!
Testing, building
-----------------
To test, run either
$ phpunit tests/
or
$ pear run-tests -r
To build, simply
$ pear package
To install from scratch
$ pear install package.xml
To upgrade
$ pear upgrade -f package.xml

View File

@@ -0,0 +1,54 @@
{
"name": "pear/archive_tar",
"description": "Tar file management class with compression support (gzip, bzip2, lzma2)",
"type": "library",
"keywords": [
"archive",
"tar"
],
"homepage": "https://github.com/pear/Archive_Tar",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Vincent Blavet",
"email": "vincent@phpconcept.net"
},
{
"name": "Greg Beaver",
"email": "greg@chiaraquartet.net"
},
{
"name": "Michiel Rook",
"email": "mrook@php.net"
}
],
"require": {
"php": ">=5.2.0",
"pear/pear-core-minimal": "^1.10.0alpha2"
},
"suggest": {
"ext-zlib": "Gzip compression support.",
"ext-bz2": "Bz2 compression support.",
"ext-xz": "Lzma2 compression support."
},
"autoload": {
"psr-0": {
"Archive_Tar": ""
}
},
"include-path": [
"./"
],
"support": {
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Archive_Tar",
"source": "https://github.com/pear/Archive_Tar"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
}
}

View File

@@ -0,0 +1,475 @@
Documentation for class Archive_Tar
===================================
Last update : 2001-08-15
Overview :
----------
The Archive_Tar class helps in creating and managing GNU TAR format
files compressed by GNU ZIP or not.
The class offers basic functions like creating an archive, adding
files in the archive, extracting files from the archive and listing
the archive content.
It also provide advanced functions that allow the adding and
extraction of files with path manipulation.
Sample :
--------
// ----- Creating the object (uncompressed archive)
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
// ----- Creating the archive
$v_list[0]="file.txt";
$v_list[1]="data/";
$v_list[2]="file.log";
$tar_object->create($v_list);
// ----- Adding files
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/";
$v_list[2]="log/file.log";
$tar_object->add($v_list);
// ----- Adding more files
$tar_object->add("release/newfile.log release/readme.txt");
// ----- Listing the content
if (($v_list = $tar_object->listContent()) != 0)
for ($i=0; $i<sizeof($v_list); $i++)
{
echo "Filename :'".$v_list[$i][filename]."'<br>";
echo " .size :'".$v_list[$i][size]."'<br>";
echo " .mtime :'".$v_list[$i][mtime]."' (".date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
echo " .mode :'".$v_list[$i][mode]."'<br>";
echo " .uid :'".$v_list[$i][uid]."'<br>";
echo " .gid :'".$v_list[$i][gid]."'<br>";
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
}
// ----- Extracting the archive in directory "install"
$tar_object->extract("install");
Public arguments :
------------------
None
Public Methods :
----------------
Method : Archive_Tar($p_tarname, $compress = null)
Description :
Archive_Tar Class constructor. This flavour of the constructor only
declare a new Archive_Tar object, identifying it by the name of the
tar file.
If the compress argument is set the tar will be read or created as a
gzip or bz2 compressed TAR file.
Arguments :
$p_tarname : A valid filename for the tar archive file.
$p_compress : can be null, 'gz' or 'bz2'. For
compatibility reason it can also be true. This
parameter indicates if gzip or bz2 compression
is required.
Return value :
The Archive_Tar object.
Sample :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object_compressed = new Archive_Tar("tarname.tgz", true);
How it works :
Initialize the object.
Method : create($p_filelist)
Description :
This method creates the archive file and add the files / directories
that are listed in $p_filelist.
If the file already exists and is writable, it is replaced by the
new tar. It is a create and not an add. If the file exists and is
read-only or is a directory it is not replaced. The method return
false and a PEAR error text.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
See also createModify() method for more details.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$v_list[0]="file.txt";
$v_list[1]="data/"; (Optional '/' at the end)
$v_list[2]="file.log";
$tar_object->create($v_list);
Sample 2 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$tar_object->create("file.txt data/ file.log");
How it works :
Just calling the createModify() method with the right parameters.
Method : createModify($p_filelist, $p_add_dir, $p_remove_dir = "")
Description :
This method creates the archive file and add the files / directories
that are listed in $p_filelist.
If the file already exists and is writable, it is replaced by the
new tar. It is a create and not an add. If the file exists and is
read-only or is a directory it is not replaced. The method return
false and a PEAR error text.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
The path indicated in $p_remove_dir will be removed from the
memorized path of each file / directory listed when this path
exists. By default nothing is removed (empty path "")
The path indicated in $p_add_dir will be added at the beginning of
the memorized path of each file / directory listed. However it can
be set to empty "". The adding of a path is done after the removing
of path.
The path add/remove ability enables the user to prepare an archive
for extraction in a different path than the origin files are.
See also addModify() method for file adding properties.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
$p_add_dir : A string which contains a path to be added to the
memorized path of each element in the list.
$p_remove_dir : A string which contains a path to be removed from
the memorized path of each element in the list, when
relevant.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$v_list[0]="file.txt";
$v_list[1]="data/"; (Optional '/' at the end)
$v_list[2]="file.log";
$tar_object->createModify($v_list, "install");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/file.log
Sample 2 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->createModify($v_list, "install", "dev");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/log/file.log
How it works :
Open the file in write mode (erasing the existing one if one),
call the _addList() method for adding the files in an empty archive,
add the tar footer (512 bytes block), close the tar file.
Method : addModify($p_filelist, $p_add_dir, $p_remove_dir="")
Description :
This method add the files / directories listed in $p_filelist at the
end of the existing archive. If the archive does not yet exists it
is created.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
The path indicated in $p_remove_dir will be removed from the
memorized path of each file / directory listed when this path
exists. By default nothing is removed (empty path "")
The path indicated in $p_add_dir will be added at the beginning of
the memorized path of each file / directory listed. However it can
be set to empty "". The adding of a path is done after the removing
of path.
The path add/remove ability enables the user to prepare an archive
for extraction in a different path than the origin files are.
If a file/dir is already in the archive it will only be added at the
end of the archive. There is no update of the existing archived
file/dir. However while extracting the archive, the last file will
replace the first one. This results in a none optimization of the
archive size.
If a file/dir does not exist the file/dir is ignored. However an
error text is send to PEAR error.
If a file/dir is not readable the file/dir is ignored. However an
error text is send to PEAR error.
If the resulting filename/dirname (after the add/remove option or
not) string is greater than 99 char, the file/dir is
ignored. However an error text is send to PEAR error.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
$p_add_dir : A string which contains a path to be added to the
memorized path of each element in the list.
$p_remove_dir : A string which contains a path to be removed from
the memorized path of each element in the list, when
relevant.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->addModify($v_list, "install");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/file.log
Sample 2 :
$tar_object = new Archive_Tar("tarname.tar");
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->addModify($v_list, "install", "dev");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/log/file.log
How it works :
If the archive does not exists it create it and add the files.
If the archive does exists and is not compressed, it open it, jump
before the last empty 512 bytes block (tar footer) and add the files
at this point.
If the archive does exists and is compressed, a temporary copy file
is created. This temporary file is then 'gzip' read block by block
until the last empty block. The new files are then added in the
compressed file.
The adding of files is done by going through the file/dir list,
adding files per files, in a recursive way through the
directory. Each time a path need to be added/removed it is done
before writing the file header in the archive.
Method : add($p_filelist)
Description :
This method add the files / directories listed in $p_filelist at the
end of the existing archive. If the archive does not yet exists it
is created.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
See addModify() method for details and limitations.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->add($v_list);
Sample 2 :
$tar_object = new Archive_Tar("tarname.tgz", true);
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->add($v_list);
How it works :
Simply call the addModify() method with the right parameters.
Method : addString($p_filename, $p_string, $p_datetime, $p_params)
Description :
This method add a single string as a file at the
end of the existing archive. If the archive does not yet exists it
is created.
Arguments :
$p_filename : A string which contains the full filename path
that will be associated with the string.
$p_string : The content of the file added in the archive.
$p_datetime : (Optional) Timestamp of the file (default = now)
$p_params : (Optional) Various file metadata:
stamp - As above, timestamp of the file
mode - UNIX-style permissions (default 0600)
type - Is this a regular file or link (see TAR
format spec for how to create a hard/symlink)
uid - UNIX-style user ID (default 0 = root)
gid - UNIX-style group ID (default 0 = root)
Return value :
true on success, false on error.
Sample 1 :
$v_archive = & new Archive_Tar($p_filename);
$v_archive->setErrorHandling(PEAR_ERROR_PRINT);
$v_result = $v_archive->addString('data/test.txt', 'This is the text of the string');
$v_result = $v_archive->addString(
'data/test.sh',
"#!/bin/sh\necho 'Hello'",
time(),
array( "mode" => 0755, "uid" => 34 )
);
Method : extract($p_path = "")
Description :
This method extract all the content of the archive in the directory
indicated by $p_path.If $p_path is optional, if not set the archive
is extracted in the current directory.
While extracting a file, if the directory path does not exists it is
created.
See extractModify() for details and limitations.
Arguments :
$p_path : Optional path where the files/dir need to by extracted.
Return value :
true on success, false on error.
Sample :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->extract();
How it works :
Simply call the extractModify() method with appropriate parameters.
Method : extractModify($p_path, $p_remove_path)
Description :
This method extract all the content of the archive in the directory
indicated by $p_path. When relevant the memorized path of the
files/dir can be modified by removing the $p_remove_path path at the
beginning of the file/dir path.
While extracting a file, if the directory path does not exists it is
created.
While extracting a file, if the file already exists it is replaced
without looking for last modification date.
While extracting a file, if the file already exists and is write
protected, the extraction is aborted.
While extracting a file, if a directory with the same name already
exists, the extraction is aborted.
While extracting a directory, if a file with the same name already
exists, the extraction is aborted.
While extracting a file/directory if the destination directory exist
and is write protected, or does not exist but can not be created,
the extraction is aborted.
If after extraction an extracted file does not show the correct
stored file size, the extraction is aborted.
When the extraction is aborted, a PEAR error text is set and false
is returned. However the result can be a partial extraction that may
need to be manually cleaned.
Arguments :
$p_path : The path of the directory where the files/dir need to by
extracted.
$p_remove_path : Part of the memorized path that can be removed if
present at the beginning of the file/dir path.
Return value :
true on success, false on error.
Sample :
// Imagine tarname.tar with files :
// dev/data/file.txt
// dev/data/log.txt
// readme.txt
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->extractModify("install", "dev");
// Files will be extracted there :
// install/data/file.txt
// install/data/log.txt
// install/readme.txt
How it works :
Open the archive and call a more generic function that can extract
only a part of the archive or all the archive.
See extractList() method for more details.
Method : extractInString($p_filename)
Description :
This method extract from the archive one file identified by $p_filename.
The return value is a string with the file content, or NULL on error.
Arguments :
$p_filename : The path of the file to extract in a string.
Return value :
a string with the file content or NULL.
Sample :
// Imagine tarname.tar with files :
// dev/data/file.txt
// dev/data/log.txt
// dev/readme.txt
$v_archive = & new Archive_Tar('tarname.tar');
$v_archive->setErrorHandling(PEAR_ERROR_PRINT);
$v_string = $v_archive->extractInString('dev/readme.txt');
echo $v_string;
Method : listContent()
Description :
This method returns an array of arrays that describe each
file/directory present in the archive.
The array is not sorted, so it show the position of the file in the
archive.
The file informations are :
$file[filename] : Name and path of the file/dir.
$file[mode] : File permissions (result of fileperms())
$file[uid] : user id
$file[gid] : group id
$file[size] : filesize
$file[mtime] : Last modification time (result of filemtime())
$file[typeflag] : "" for file, "5" for directory
Arguments :
Return value :
An array of arrays or 0 on error.
Sample :
$tar_object = new Archive_Tar("tarname.tar");
if (($v_list = $tar_object->listContent()) != 0)
for ($i=0; $i<sizeof($v_list); $i++)
{
echo "Filename :'".$v_list[$i][filename]."'<br>";
echo " .size :'".$v_list[$i][size]."'<br>";
echo " .mtime :'".$v_list[$i][mtime]."' (".
date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
echo " .mode :'".$v_list[$i][mode]."'<br>";
echo " .uid :'".$v_list[$i][uid]."'<br>";
echo " .gid :'".$v_list[$i][gid]."'<br>";
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
}
How it works :
Call the same function as an extract however with a flag to only go
through the archive without extracting the files.
Method : extractList($p_filelist, $p_path = "", $p_remove_path = "")
Description :
This method extract from the archive only the files indicated in the
$p_filelist. These files are extracted in the current directory or
in the directory indicated by the optional $p_path parameter.
If indicated the $p_remove_path can be used in the same way as it is
used in extractModify() method.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
$p_path : The path of the directory where the files/dir need to by
extracted.
$p_remove_path : Part of the memorized path that can be removed if
present at the beginning of the file/dir path.
Return value :
true on success, false on error.
Sample :
// Imagine tarname.tar with files :
// dev/data/file.txt
// dev/data/log.txt
// readme.txt
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->extractList("dev/data/file.txt readme.txt", "install",
"dev");
// Files will be extracted there :
// install/data/file.txt
// install/readme.txt
How it works :
Go through the archive and extract only the files present in the
list.

View File

@@ -0,0 +1,712 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.9.4" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>Archive_Tar</name>
<channel>pear.php.net</channel>
<summary>Tar file management class</summary>
<description>This class provides handling of tar files in PHP.
It supports creating, listing, extracting and adding to tar files.
Gzip support is available if PHP has the zlib extension built-in or
loaded. Bz2 compression is also supported with the bz2 extension loaded.
Also Lzma2 compressed archives are supported with xz extension.</description>
<lead>
<name>Vincent Blavet</name>
<user>vblavet</user>
<email>vincent@phpconcept.net</email>
<active>no</active>
</lead>
<lead>
<name>Greg Beaver</name>
<user>cellog</user>
<email>greg@chiaraquartet.net</email>
<active>no</active>
</lead>
<lead>
<name>Michiel Rook</name>
<user>mrook</user>
<email>mrook@php.net</email>
<active>yes</active>
</lead>
<helper>
<name>Stig Bakken</name>
<user>ssb</user>
<email>stig@php.net</email>
<active>no</active>
</helper>
<date>2021-07-20</date>
<time>18:00:00</time>
<version>
<release>1.4.14</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Properly fix symbolic link path traversal (CVE-2021-32610)
</notes>
<contents>
<dir name="/">
<dir name="Archive">
<file baseinstalldir="/" name="Tar.php" role="php" />
</dir> <!-- /Archive -->
<dir name="docs">
<file baseinstalldir="/" name="Archive_Tar.txt" role="doc" />
</dir> <!-- /docs -->
</dir> <!-- / -->
</contents>
<compatible>
<name>PEAR</name>
<channel>pear.php.net</channel>
<min>1.8.0</min>
<max>1.10.10</max>
</compatible>
<dependencies>
<required>
<php>
<min>5.2.0</min>
</php>
<pearinstaller>
<min>1.9.0</min>
</pearinstaller>
</required>
</dependencies>
<phprelease />
<changelog>
<release>
<version>
<release>1.4.13</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2021-02-16</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #27010: Relative symlinks failing (out-of path file extraction) [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.12</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2021-01-18</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #27008: Symlink out-of-path write vulnerability (CVE-2020-36193) [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.11</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2020-11-19</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #27002: Filename manipulation vulnerabilities (CVE-2020-28948 / CVE-2020-28949) [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.10</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2020-09-15</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix block padding when the file buffer length is a multiple of 512 and smaller than Archive_Tar buffer length
* Don&apos;t try to copy username/groupname in chroot jail
</notes>
</release>
<release>
<version>
<release>1.4.9</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2019-12-04</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Implement Feature #23861: Add option to disallow symlinks [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.8</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2019-10-21</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #23852: PHP 7.4 - Archive_Tar-&gt;_readHeader throws deprecation [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.7</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2019-04-08</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Improved performance by increasing read buffer size
</notes>
</release>
<release>
<version>
<release>1.4.6</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2019-02-01</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Improve path traversal detection for forward and backward slashes
</notes>
</release>
<release>
<version>
<release>1.4.5</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2019-01-02</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #23788: Relative symlinks are broken [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.4</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2018-12-20</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #21058: Long symlinks are not supported [mrook]
* Fix Bug #23782: Prevent phar:// files from being extracted [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.3</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2017-06-11</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #21218: Cannot use result of built-in function in write context in PHP
7.2.0alpha1 [mrook]
</notes>
</release>
<release>
<version>
<release>1.4.2</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2016-02-25</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix reading of archives with files &gt; 8GB
* Performance optimizations
* Do not try to call require_once on PEAR.php if it has already been loaded by the autoloader
</notes>
</release>
<release>
<version>
<release>1.4.1</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2015-08-05</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Update composer.json to use pear-core-minimal 1.10.0alpha2
</notes>
</release>
<release>
<version>
<release>1.4.0</release>
<api>1.4.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2015-07-20</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Add support for PHP 7
* Drop support for PHP 4
* Add visibility declarations to methods and properties
</notes>
</release>
<release>
<version>
<release>1.3.16</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2015-04-14</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #20514: invalid package.xml; not installable with pyrus [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.15</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2015-03-05</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fixes composer.json parse error
</notes>
</release>
<release>
<version>
<release>1.3.14</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2015-02-26</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #18505: Possible incorrect handling of file names in TAR [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.13</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2014-09-02</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD
License</license>
<notes>
* Fix Bug #20382: gzopen fix [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.12</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2014-08-04</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD
License</license>
<notes>
* Fix Bug #19964: Memory leaking in Archive_Tar [mrook]
* Fix Bug #20246: Broken with php 5.5.9 [mrook]
* Fix Bug #20275: &quot;pax_global_header&quot; looks like a regular file
* [mrook]
* Implement Feature #19827: pass filename to _addFile function - downstream
* patch [mrook]
* Implement Feature #20132: Add custom mode/uid/gid to addString() [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.11</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2013-02-09</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD
License</license>
<notes>
* Fix Bug #19746: Broken with PHP 5.5 [mrook]
* Implement Feature #11258: Custom date/time in files added on-the-fly
* [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.10</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2012-04-10</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD
License</license>
<notes>
* Fix Bug #13361: Unable to add() some files (ex. mp3) [mrook]
* Fix Bug #19330: Class creates incorrect (non-readable) tar.gz file
* [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.9</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2012-02-27</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #16759: No error thrown from missing PHP zlib functions [mrook]
* Fix Bug #18877: Incorrect handling of backslashes in filenames on Linux [mrook]
* Fix Bug #19085: Error while packaging [mrook]
* Fix Bug #19289: Invalid tar file generated [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.8</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2011-10-14</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #17853: Test failure: dirtraversal.phpt [mrook]
* Fix Bug #18512: dead links are not saved in tar file [mrook]
* Fix Bug #18702: Unpacks incorrectly on long file names using header prefix [mrook]
* Implement Feature #10145: Patch to return a Pear Error Object on failure [mrook]
* Implement Feature #17491: Option to preserve permissions [mrook]
* Implement Feature #17813: Prevent PHP notice when extracting corrupted archive [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.7</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-04-26</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
PEAR compatibility update
</notes>
</release>
<release>
<version>
<release>1.3.6</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2010-03-09</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #16963: extractList can&apos;t extract zipped files from big tar [mrook]
* Implement Feature #4013: Ignoring files and directories on creating an archive. [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.5</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2009-12-31</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #16958: Update &apos;compatible&apos; tag in package.xml [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.4</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2009-12-30</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
* Fix Bug #11871: wrong result of ::listContent() if filename begins or ends with space [mrook]
* Fix Bug #12462: invalid tar magic [mrook]
* Fix Bug #13918: Long filenames may get up to 511 0x00 bytes appended on read [mrook]
* Fix Bug #16202: Bogus modification times [mrook]
* Implement Feature #16212: Die is not exception [mrook]
</notes>
</release>
<release>
<version>
<release>1.3.3</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2009-03-27</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
Change the license to New BSD license
minor bugfix release
* fix Bug #9921 compression with bzip2 fails [cellog]
* fix Bug #11594 _readLongHeader leaves 0 bytes in filename [jamessas]
* fix Bug #11769 Incorrect symlink handing [fajar99]
</notes>
</release>
<release>
<version>
<release>1.3.2</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2007-01-03</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Correct Bug #4016
Remove duplicate remove error display with &apos;@&apos;
Correct Bug #3909 : Check existence of OS_WINDOWS constant
Correct Bug #5452 fix for &quot;lone zero block&quot; when untarring packages
Change filemode (from pear-core/Archive/Tar.php v.1.21)
Correct Bug #6486 Can not extract symlinks
Correct Bug #6933 Archive_Tar (Tar file management class) Directory traversal
Correct Bug #8114 Files added on-the-fly not storing date
Correct Bug #9352 Bug on _dirCheck function over nfs path
</notes>
</release>
<release>
<version>
<release>1.3.1</release>
<api>1.3.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2005-03-17</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Correct Bug #3855
</notes>
</release>
<release>
<version>
<release>1.3.0</release>
<api>1.3.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2005-03-06</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Bugs correction (2475, 2488, 2135, 2176)
</notes>
</release>
<release>
<version>
<release>1.2</release>
<api>1.2</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2004-05-08</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Add support for other separator than the space char and bug
correction
</notes>
</release>
<release>
<version>
<release>1.1</release>
<api>1.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2003-05-28</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
* Add support for BZ2 compression
* Add support for add and extract without using temporary files : methods addString() and extractInString()
</notes>
</release>
<release>
<version>
<release>1.0</release>
<api>1.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2003-01-24</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Change status to stable
</notes>
</release>
<release>
<version>
<release>0.10-b1</release>
<api>0.10-b1</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2003-01-08</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Add support for long filenames (greater than 99 characters)
</notes>
</release>
<release>
<version>
<release>0.9</release>
<api>0.9</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2002-05-27</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Auto-detect gzip&apos;ed files
</notes>
</release>
<release>
<version>
<release>0.4</release>
<api>0.4</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2002-05-20</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Windows bugfix: use forward slashes inside archives
</notes>
</release>
<release>
<version>
<release>0.2</release>
<api>0.2</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2002-02-18</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
From initial commit to stable
</notes>
</release>
<release>
<version>
<release>0.3</release>
<api>0.3</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2002-04-13</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
Windows bugfix: used wrong directory separators
</notes>
</release>
</changelog>
</package>

View File

@@ -0,0 +1,236 @@
#!@prefix@/bin/php -Cq
<?php // -*- PHP -*-
// {{{ setup
define('S_IFDIR', 0040000); // Directory
define('S_IFCHR', 0020000); // Character device
define('S_IFBLK', 0060000); // Block device
define('S_IFREG', 0100000); // Regular file
define('S_IFIFO', 0010000); // FIFO
define('S_IFLNK', 0120000); // Symbolic link
define('S_IFSOCK', 0140000); // Socket
require_once "PEAR.php";
require_once "Archive/Tar.php";
require_once "Console/Getopt.php";
// }}}
// {{{ options
$verbose = false;
$op_create = false;
$op_list = false;
$op_extract = false;
$use_gzip = false;
$file = '';
$progname = basename(array_shift($argv));
$options = Console_Getopt::getopt($argv, "h?ctxvzf:");
if (PEAR::isError($options)) {
usage($options);
}
$opts = $options[0];
foreach ($opts as $opt) {
switch ($opt[0]) {
case 'v': {
$verbose = true;
break;
}
case 'c': {
$op_create = true;
break;
}
case 't': {
$op_list = true;
break;
}
case 'x': {
$op_extract = true;
break;
}
case 'z': {
$use_gzip = true;
break;
}
case 'f': {
$file = $opt[1];
break;
}
case 'h':
case '?': {
usage();
break;
}
}
}
if ($op_create + $op_list + $op_extract > 1) {
usage("Only one of -c, -t and -x can be specified at once!");
}
if ($op_create + $op_list + $op_extract == 0) {
usage("Please specify either -c, -t or -x!");
}
if (empty($file)) {
if ($op_create) {
$file = "php://stdout";
} else {
$file = "php://stdin";
}
}
// }}}
$tar = new Archive_Tar($file, $use_gzip);
$tar->setErrorHandling(PEAR_ERROR_DIE, "$progname error: %s\n");
if ($op_create) {
do_create($tar, $options[1]);
$tar->create($options[1]);
} elseif ($op_list) {
do_list($tar, $verbose);
} elseif ($op_extract) {
do_extract($tar);
}
// {{{ getrwx()
function getrwx($bits) {
$str = '';
$str .= ($bits & 4) ? 'r' : '-';
$str .= ($bits & 2) ? 'w' : '-';
$str .= ($bits & 1) ? 'x' : '-';
return $str;
}
// }}}
// {{{ getfiletype()
function getfiletype($bits) {
static $map = array(
'-' => S_IFREG,
'd' => S_IFDIR,
'l' => S_IFLNK,
'c' => S_IFCHR,
'b' => S_IFBLK,
'p' => S_IFIFO,
's' => S_IFSOCK,
);
foreach ($map as $char => $mask) {
if ($bits & $mask) {
return $char;
}
}
}
// }}}
// {{{ getuser()
function getuser($uid) {
static $cache = array();
if (isset($cache[$uid])) {
return $cache[$uid];
}
if (function_exists("posix_getpwuid")) {
if (is_array($user = @posix_getpwuid($uid))) {
$cache[$uid] = $user['name'];
return $user['name'];
}
}
$cache[$uid] = $uid;
return $uid;
}
// }}}
// {{{ getgroup()
function getgroup($gid) {
static $cache = array();
if (isset($cache[$gid])) {
return $cache[$gid];
}
if (function_exists("posix_getgrgid")) {
if (is_array($group = @posix_getgrgid($gid))) {
$cache[$gid] = $group['name'];
return $group['name'];
}
}
$cache[$gid] = $gid;
return $gid;
}
// }}}
// {{{ do_create()
function do_create(&$tar, &$files)
{
$tar->create($files);
}
// }}}
// {{{ do_list()
function do_list(&$tar, $verbose)
{
static $rwx = array(4 => 'r', 2 => 'w', 1 => 'x');
$files = $tar->listContent();
if (is_array($files) && sizeof($files) > 0) {
foreach ($files as $file) {
if ($verbose) {
$fm = (int)$file['mode'];
$mode = sprintf('%s%s%s%s', getfiletype($fm),
getrwx(($fm >> 6) & 7), getrwx(($fm >> 3) & 7),
getrwx($fm & 7));
$owner = getuser($file['uid']) . '/' . getgroup($file['gid']);
printf("%10s %-11s %7d %s %s\n", $mode, $owner, $file['size'],
date('Y-m-d H:i:s', $file['mtime']), $file['filename']);
} else {
printf("%s\n", $file['filename']);
}
}
}
}
// }}}
// {{{ do_extract()
function do_extract(&$tar, $destdir = ".")
{
$tar->extract($destdir);
}
// }}}
// {{{ usage()
function usage($errormsg = '')
{
global $progname;
$fp = fopen("php://stderr", "w");
if ($errormsg) {
if (PEAR::isError($errormsg)) {
fwrite($fp, $errormsg->getMessage() . "\n");
} else {
fwrite($fp, "$errormsg\n");
}
}
fwrite($fp, "$progname [-h|-?] {-c|-t|-x} [-z] [-v] [-f file] [file(s)...]
Options:
-h, -? Show this screen
-c Create archive
-t List archive
-x Extract archive
-z Run input/output through gzip
-f file Use <file> as input or output (default is stdin/stdout)
");
fclose($fp);
exit;
}
// }}}
?>

View File

@@ -0,0 +1,6 @@
#!/bin/sh
rsync -av Archive/Tar.php ../../php4/pear/Archive/.
rsync -av package.xml ../../php4/pear/package-Archive_Tar.xml
rsync -av docs/Archive_Tar.txt ../../php4/pear/docs/.

View File

@@ -0,0 +1,33 @@
--TEST--
test file size that happens to be 512 * n bytes
--SKIPIF--
--FILE--
<?php
$dirname = dirname(__FILE__);
require_once $dirname . '/setup.php.inc';
$tar = new Archive_Tar($dirname . '/512nbytesfile.tar.gz', null, 2048);
$tar->add($dirname .'/testblock3');
$tar->listContent();
$phpunit->assertNoErrors('after tar archive listing');
$returnval = shell_exec('tar -Ptf ' . $dirname . '/512nbytesfile.tar.gz | sort');
$phpunit->assertNoErrors('after shell tar listing');
$expectedvalue =
<<< EOD
$dirname/testblock3
$dirname/testblock3/1024bytes.txt
$dirname/testblock3/randombytes.txt
EOD;
$phpunit->assertEquals($expectedvalue, $returnval, 'wrong output for shell tar verification');
echo 'test done'
?>
--CLEAN--
<?php
$dirname = dirname(__FILE__);
@unlink($dirname.'/512nbytesfile.tar.gz');
?>
--EXPECT--
test done

View File

@@ -0,0 +1,46 @@
--TEST--
test saving of dead symbolic links
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
function fileName($item){
return rtrim($item['filename'],'/').' => '.$item['link'];
}
//prepare filesystem
@mkdir('test');
@mkdir('test/a');
@touch('test/b');
@symlink('a', 'test/dir_link');
@symlink('b', 'test/file_link');
@symlink('dead', 'test/dead_link');
//prepare reference tar
system('tar -cf test1.tar test');
$tar1=new Archive_Tar('test1.tar');
$tar1List=array_map('fileName',$tar1->listContent());
//create tar
$tar2=new Archive_Tar('test2.tar');
$tar2->create(array('test','nonExisting'));// to make sure we are still report nonExisting
$tar2List=array_map('fileName',$tar2->listContent());
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' => "File 'nonExisting' does not exist")), 'after 1');
$phpunit->assertEquals($tar1List, $tar2List, 'bla');
echo 'tests done';
?>
--CLEAN--
<?php
@rmdir('test/a');
@unlink('test/b');
@unlink('test/dir_link');
@unlink('test/file_link');
@unlink('test/dead_link');
@rmdir('test');
@unlink('test1.tar');
@unlink('test2.tar');
?>
--EXPECT--
tests done

View File

@@ -0,0 +1,24 @@
--TEST--
test directory traversal security vulnerability
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$me = dirname(__FILE__) . '/testit';
$tar = new Archive_Tar(dirname(__FILE__) . '/hamidTARtester2.tar');
$tar->listContent();
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' => 'Malicious .tar detected, file "/../../../../../../../../../../../../../../AAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB.txt" will not install in desired directory tree')
), 'after 1');
$tar->extract();
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' => 'Malicious .tar detected, file "/../../../../../../../../../../../../../../AAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB.txt" will not install in desired directory tree')
), 'after 2');
echo 'tests done';
?>
--CLEAN--
<?php
@rmdir('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa');
?>
--EXPECT--
tests done

Binary file not shown.

View File

@@ -0,0 +1,20 @@
--TEST--
test files that happen to contain the endblock
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$tar = new Archive_Tar(dirname(__FILE__) . '/testblock.tar.gz');
$tar->add(dirname(__FILE__) . '/testblock1');
$tar->add(dirname(__FILE__) . '/testblock2');
$tar = new Archive_Tar(dirname(__FILE__) . '/testblock.tar.gz');
$tar->listContent();
$phpunit->assertNoErrors('after');
echo 'tests done';
?>
--CLEAN--
<?php
@unlink(dirname(__FILE__) . '/testblock.tar.gz');
?>
--EXPECT--
tests done

View File

@@ -0,0 +1,20 @@
--TEST--
test saving of dead symbolic links
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$tar1 = new Archive_Tar(dirname(__FILE__) . '/text-0.txt');
$tar1->listContent();
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' => "Invalid checksum for file \"4&2Vib~Au.=ZqMTw~=}UoF/~5Gs;JTXF*<FyG\"\n" .
'1Hvu#nol Y 21/{G9i|D=$GTI KREuA\wI<wM@dYOKzS{6&]QE8ud|EPb:f?-Gt' . "\n" .
'I#)E9)@;_.0y9`P,&jY! :\.J8uG/a8,.vT[$Fe;>}hm\"#xO7:46y_tg6c-[A&S]z0fke?(B6?$:W$X{E%PO>~UWl8(' . "\n" .
'.%RWPjN55)cd&?oJPgFFZj#+U<qrF:9yIRe\" : UPJX05Zz extracted')), 'after 1');
echo 'tests done';
?>
--CLEAN--
--EXPECT--
tests done

View File

@@ -0,0 +1,30 @@
--TEST--
test trimming of characters in long filenames
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$dirname = dirname(__FILE__) . '/longfilenamedir/';
for ($i = 0; $i < 8; $i++) {
$dirname .= str_pad('', 64, 'a') . '/';
}
$longfilename = $dirname . "b ";
mkdir($dirname, 0777, true);
touch($longfilename);
$tar = new Archive_Tar(dirname(__FILE__) . '/testlongfilename.tar');
$tar->addModify(array($longfilename), '', dirname(__FILE__));
$tar = new Archive_Tar(dirname(__FILE__) . '/testlongfilename.tar');
$files = $tar->listContent();
$file = reset($files);
$lastChar = $file['filename'][strlen($file['filename']) - 1];
$phpunit->assertEquals(' ', $lastChar, 'should contain space as last character');
echo 'tests done';
?>
--CLEAN--
<?php
$dirname = dirname(__FILE__);
unlink($dirname . '/testlongfilename.tar');
system("rm -r $dirname/longfilenamedir");
?>
--EXPECT--
tests done

View File

@@ -0,0 +1,29 @@
--TEST--
test trimming of characters in long symbolic link targets
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$dirname = dirname(__FILE__) . '/longsymlink/';
$longfilename = $dirname . str_repeat("b", 120) . " ";
$symlinkfilename = $dirname . "a";
mkdir($dirname, 0777, true);
touch($longfilename);
symlink($longfilename, $symlinkfilename);
$tar = new Archive_Tar(dirname(__FILE__) . '/testlongsymlink.tar');
$tar->addModify(array($longfilename, $symlinkfilename), '', dirname(__FILE__));
$tar = new Archive_Tar(dirname(__FILE__) . '/testlongsymlink.tar');
$files = $tar->listContent();
$file = end($files);
$lastChar = $file['link'][strlen($file['link']) - 1];
$phpunit->assertEquals(' ', $lastChar, 'should contain space as last character');
echo 'tests done';
?>
--CLEAN--
<?php
$dirname = dirname(__FILE__);
unlink($dirname . '/testlongsymlink.tar');
system("rm -r $dirname/longsymlink");
?>
--EXPECT--
tests done

View File

@@ -0,0 +1,18 @@
--TEST--
tests writes to out-of-path filenames
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$tar = new Archive_Tar(dirname(__FILE__) . '/out_of_path_symlink.tar');
$tar->extract();
$phpunit->assertErrors(array(array('package' => 'PEAR_Error', 'message' => "Out-of-path file extraction {symlink --> /tmp/}")), 'after 1');
$phpunit->assertFileNotExists('symlink/whatever-filename', 'Out-of-path filename should not have succeeded');
echo 'tests done';
?>
--CLEAN--
<?php
@unlink("symlink");
?>
--EXPECT--
tests done

View File

@@ -0,0 +1,13 @@
--TEST--
tests if pax global / extended headers are ignored
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$tar = new Archive_Tar(dirname(__FILE__) . '/testpax.tar');
$phpunit->assertEquals(1, count($tar->listContent()), "count should be 1");
echo 'tests done';
?>
--CLEAN--
--EXPECT--
tests done

View File

@@ -0,0 +1,18 @@
--TEST--
test preserving of permissions
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$tar = new Archive_Tar(dirname(__FILE__) . '/testperms.tar');
$tar->extract('', true);
$phpunit->assertNoErrors('after');
echo 'tests done';
?>
--CLEAN--
<?php
@unlink('a');
@unlink('b');
?>
--EXPECT--
tests done

View File

@@ -0,0 +1,414 @@
<?php
@include_once 'Text/Diff.php';
@include_once 'Text/Diff/Renderer.php';
@include_once 'Text/Diff/Renderer/unified.php';
require_once 'PEAR/ErrorStack.php';
require_once 'PEAR.php';
class PEAR_PHPTest
{
var $_diffonly;
var $_errors;
function __construct($diffonly = false, $noStackCatch = false)
{
$this->_diffonly = $diffonly;
$this->_errors = array();
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'pearerrorCallback'));
if (!$noStackCatch) {
PEAR_ErrorStack::setDefaultCallback(array($this, 'pearerrorstackCallback'));
}
}
function pearerrorCallback($err)
{
PEAR_ErrorStack::staticPush('PEAR_Error', -1, 'error', array('obj' => $err),
$err->getMessage());
}
function pearerrorstackCallback($err)
{
$this->_errors[] = $err;
}
function assertPEARError($err, $message)
{
if (is_a($err, 'PEAR_Error')) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Not a PEAR_Error\n";
return false;
}
function assertNoErrors($message, $trace = null)
{
if (count($this->_errors) == 0) {
return true;
}
if ($trace === null) {
$trace = debug_backtrace();
}
$this->_failTest($trace, $message);
foreach ($this->_errors as $err) {
if ($err['package'] == 'PEAR_Error') {
echo "Unexpected PEAR_Error:\n";
echo 'message "' . $err['message'] . "\"\n";
} else {
echo "Unexpected PEAR_ErrorStack error:\n";
echo 'package "' . $err['package'] . "\"\n";
echo 'message "' . $err['message'] . "\"\n";
}
}
$this->_errors = array();
return false;
}
function assertErrors($errors, $message, $trace = null)
{
if (!count($this->_errors)) {
if ($trace === null) {
$trace = debug_backtrace();
}
$this->_failTest($trace, $message);
echo "No errors caught, but errors were expected\n";
return false;
}
if (!isset($errors[0])) {
$errors = array($errors);
}
$failed = false;
foreach ($errors as $err) {
$found = false;
foreach ($this->_errors as $i => $caughterror) {
if ($caughterror['package'] == $err['package']) {
if ($caughterror['message'] == $err['message']) {
$found = true;
break;
}
}
}
if ($found) {
unset($this->_errors[$i]);
continue;
}
if (!$failed) {
if ($trace === null) {
$trace = debug_backtrace();
}
$failed = true;
$this->_failTest($trace, $message);
}
echo "Unthrown error:\n";
if ($err['package'] == 'PEAR_Error') {
echo "PEAR_Error:\n";
} else {
echo "error package: \"$err[package]\"\n";
}
echo "message: \"$err[message]\"\n";
}
if (count($this->_errors)) {
if (!$failed) {
if ($trace === null) {
$trace = debug_backtrace();
}
$failed = true;
$this->_failTest($trace, $message);
}
foreach ($this->_errors as $err) {
echo "Unexpected error:\n";
if ($err['package'] == 'PEAR_Error') {
echo "PEAR_Error:\n";
} else {
echo "error package: \"$err[package]\"\n";
}
echo "message: \"$err[message]\"\n";
}
}
$this->_errors = array();
return !$failed;
}
function assertTrue($test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if ($test === true) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpected non-true value: \n";
var_export($test);
echo "\n'$message'\n";
return false;
}
function assertIsa($control, $test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if (is_a($test, $control)) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpected non-$control object: \n";
var_export($test);
echo "\n'$message'\n";
return false;
}
function assertNull($test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if ($test === null) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpected non-null value: \n";
var_export($test);
echo "\n'$message'\n";
return false;
}
function assertNotNull($test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if ($test !== null) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpected null: \n";
var_export($test);
echo "\n'$message'\n";
return false;
}
function assertSame($test, $test1, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if ($test === $test1) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpectedly two vars are not the same thing: \n";
echo "\n'$message'\n";
return false;
}
function assertNotSame($test, $test1, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if ($test !== $test1) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpectedly two vars are the same thing: \n";
echo "\n'$message'\n";
return false;
}
function assertFalse($test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if ($test === false) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpected non-false value: \n";
var_export($test);
echo "\n'$message'\n";
return false;
}
function assertNotTrue($test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if (!$test) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpected loose true value: \n";
var_export($test);
echo "\n'$message'\n";
return false;
}
function assertNotFalse($test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if ($test) {
return true;
}
$this->_failTest(debug_backtrace(), $message);
echo "Unexpected loose false value: \n";
var_export($test);
echo "\n'$message'\n";
return false;
}
function assertEquals($control, $test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if (str_replace(array("\r", "\n"), array('', ''),
var_export($control, true)) != str_replace(array("\r", "\n"), array('', ''),
var_export($test, true))) {
$this->_failTest(debug_backtrace(), $message);
if (class_exists('Text_Diff')) {
echo "Diff of expecting/received:\n";
$diff = new Text_Diff(
explode("\n", var_export($control, true)),
explode("\n", var_export($test, true)));
// Output the diff in unified format.
$renderer = new Text_Diff_Renderer_unified();
echo $renderer->render($diff);
if ($this->_diffonly) {
return false;
}
}
echo "Expecting:\n";
var_export($control);
echo "\nReceived:\n";
var_export($test);
echo "\n";
return false;
}
return true;
}
function assertFileExists($fname, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if (!@file_exists($fname)) {
$this->_failTest(debug_backtrace(), $message);
echo "File '$fname' does not exist, and should\n";
return false;
}
return true;
}
function assertFileNotExists($fname, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if (@file_exists($fname)) {
$this->_failTest(debug_backtrace(), $message);
echo "File '$fname' exists, and should not\n";
return false;
}
return true;
}
function assertRegEquals($dump, &$reg, $message)
{
$actualdump = var_export(trim($this->dumpReg($reg)), true);
$testdump = var_export(trim($dump), true);
return $this->assertEquals($testdump, $actualdump, $message);
}
function assertPackageInfoEquals($control, $test, $message)
{
$this->assertNoErrors($message, debug_backtrace());
if (isset($control[0])) {
if (!isset($test[0]) || (count($control) != count($test))) {
echo "Invalid packageInfo\n";
$ret = $this->assertEquals($control, $test, $message);
}
$ret = true;
foreach ($control as $i => $packageinfo) {
$ret = $ret &&
$this->assertPackageInfoEquals($packageinfo, $test[$i], $message . $i);
}
return $ret;
}
if (isset($control['_lastmodified'])) {
if (!isset($test['_lastmodified'])) {
echo "_lastmodified is not set in packageInfo() output\n";
$this->_failTest(debug_backtrace(), $message);
return false;
}
}
$savecontrol = sort($control);
$savetest = sort($test);
unset($control['_lastmodified']);
unset($test['_lastmodified']);
if (var_export($control, true) != var_export($test, true)) {
$this->_failTest(debug_backtrace(), $message);
if (class_exists('Text_Diff')) {
echo "Diff of expecting/received:\n";
$diff = new Text_Diff(
explode("\n", var_export($control, true)),
explode("\n", var_export($test, true)));
// Output the diff in unified format.
$renderer = new Text_Diff_Renderer_unified();
echo $renderer->render($diff);
if ($this->_diffonly) {
return false;
}
}
echo "Expecting:\n";
var_export($savecontrol);
echo "\nReceived:\n";
var_export($savetest);
return false;
}
return true;
}
function _sortRegEntries($a, $b)
{
return strnatcasecmp($a['name'], $b['name']);
}
function dumpReg(&$reg)
{
ob_start();
print "dumping registry...\n";
$infos = $reg->packageInfo(null, null, null);
ksort($infos);
foreach ($infos as $channel => $info) {
echo "channel $channel:\n";
usort($info, array($this, '_sortRegEntries'));
foreach ($info as $pkg) {
print $pkg["name"] . ":";
unset($pkg["name"]);
foreach ($pkg as $k => $v) {
if ($k == '_lastmodified') {
print " _lastmodified is set";
continue;
}
if (is_array($v) && $k == 'filelist') {
print " $k=array(";
$i = 0;
foreach ($v as $k2 => $v2) {
if ($i++ > 0) print ",";
print "{$k2}[";
$j = 0;
foreach ($v2 as $k3 => $v3) {
if ($j++ > 0) print ",";
print "$k3=$v3";
}
print "]";
}
print ")";
} else {
print " $k=\"$v\"";
}
}
print "\n";
}
}
print "dump done\n";
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
function _failTest($trace, $message)
{
echo 'Test Failure: "' . $message . "\"\n in " . $trace[0]['file'] . ' line ' .
$trace[0]['line'] . "\n";
}
function showAll()
{
$this->_diffonly = false;
}
}
?>

View File

@@ -0,0 +1,26 @@
--TEST--
test symbolic links
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$me = dirname(__FILE__) . '/testit';
$tar = new Archive_Tar(dirname(__FILE__) . '/relativesymlink.tar');
$tar->extract();
$phpunit->assertNoErrors('after');
$phpunit->assertFileExists('testme', 'dir');
$phpunit->assertFileExists('testme/a/file1.txt', 'file1.txt');
$phpunit->assertFileExists('testme/b/symlink.txt', 'symlink.txt');
$phpunit->assertTrue(is_link('testme/b/symlink.txt'), 'is link');
echo 'tests done';
?>
--CLEAN--
<?php
@unlink('testme/a/file1.txt');
@unlink('testme/b/symlink.txt');
@rmdir('testme/a');
@rmdir('testme/b');
@rmdir('testme');
?>
--EXPECT--
tests done

Binary file not shown.

View File

@@ -0,0 +1,5 @@
<?php
error_reporting(E_ALL);
require_once dirname(__FILE__) . '/phpt_test.php.inc';
$phpunit = new PEAR_PHPTest(true);
require_once dirname(dirname(__FILE__)) . '/Archive/Tar.php';

View File

@@ -0,0 +1,24 @@
--TEST--
test symbolic links
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$me = dirname(__FILE__) . '/testit';
$tar = new Archive_Tar(dirname(__FILE__) . '/testsymlink.tar');
$tar->extract();
$phpunit->assertNoErrors('after');
$phpunit->assertFileExists('testme', 'dir');
$phpunit->assertFileExists('testme/file1.txt', 'file1.txt');
$phpunit->assertFileExists('testme/symlink.txt', 'symlink.txt');
$phpunit->assertTrue(is_link('testme/symlink.txt'), 'is link');
echo 'tests done';
?>
--CLEAN--
<?php
@unlink('testme/file1.txt');
@unlink('testme/symlink.txt');
@rmdir('testme');
?>
--EXPECT--
tests done

View File

@@ -0,0 +1,28 @@
--TEST--
test symbolic links
--SKIPIF--
--FILE--
<?php
require_once dirname(__FILE__) . '/setup.php.inc';
$me = dirname(__FILE__) . '/testit';
$tar = new Archive_Tar(dirname(__FILE__) . '/testsymlink.tar');
$tar->extract('', false, false);
$phpunit->assertErrors(array(
array(
'package' => 'PEAR_Error',
'message' => 'Symbolic links are not allowed. Unable to extract {testme/symlink.txt}'
),
), 'Warning thrown');
$phpunit->assertFileExists('testme', 'dir');
$phpunit->assertFileNotExists('testme/file1.txt', 'file1.txt');
$phpunit->assertFileNotExists('testme/symlink.txt', 'symlink.txt');
echo 'tests done';
?>
--CLEAN--
<?php
@unlink('testme/file1.txt');
@unlink('testme/symlink.txt');
@rmdir('testme');
?>
--EXPECT--
tests done

View File

@@ -0,0 +1 @@
abc

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,16 @@
194 210 54 166 74 179 115 216 109 21 220 29 144 242 90 206
240 73 172 14 153 163 43 16 233 20 186 91 95 150 60 61
180 187 233 126 130 154 116 206 213 231 202 148 148 12 125 24
6 139 32 235 117 240 56 96 23 1 182 167 116 64 92 73
250 177 157 119 121 148 112 50 89 24 37 214 81 88 201 75
162 108 60 114 137 227 170 186 231 213 177 33 44 143 243 98
14 28 226 77 152 241 243 62 103 237 187 235 227 73 9 119
162 64 127 74 73 90 112 200 39 6 173 251 12 191 166 18
235 100 74 184 126 153 23 118 27 25 128 222 234 246 165 159
170 127 236 199 91 67 96 185 108 159 172 2 245 202 161 177
147 188 0 151 251 230 251 100 226 67 212 38 72 32 44 117
10 39 163 159 0 197 160 225 25 177 16 0 240 16 137 105
187 132 129 98 24 210 169 33 246 77 217 145 242 118 181 47
160 61 62 129 71 52 253 85 2 215 174 241 55 32 236 27
160 120 145 188 132 37 161 178 45 227 209 57 142 19 88 175
230 238 104 128 26 196 126 118 214 122 201 123

View File

@@ -0,0 +1,2 @@
250 97 98 194 5 149 229 27 58 62 133 73 95 230 219 128
224 98 210 250 162 58 240 80 202 249 173 203 125 186

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,16 @@
a8,.vT[$Fe;>}hm\"#xO7:46y_tg6c-[A&S]z0fke?(B6?$:W$X{E%PO>~UWl8(
.%RWPjN55)cd&?oJPgFFZj#+U<qrF:9yIRe\S0F}Y|[`+4^::byA2Is7UY8QShd
v]F 1O0_[Ip7.12B"!u!UPJX05ZzKXP<JJ(X@4r(M2D})|TA@b#2zFlG(EQqT@M
[RKXlK41}Q= uEq4`p"ons9eil/$Tbp>T~!xcu46(QhbViq%FShbsm5Qt:8}[V1
ov!|iNrfBH)JBa)G?P*v!@=?:Y^2!)v `wxPQ^xT[~W6&q^Un@"c#g3=M++ 0.x
]^Lo4{|}Q]YN?GSaA/*s,Az>04&2Vib~Au.=ZqMTw~=}UoF/~5Gs;JTXF*<FyG"
1Hvu#nol Y 21/{G9i|D=$GTI KREuA\wI<wM@dYOKzS{6&]QE8ud|EPb:f?-Gt
I#)E9)@;_.0y9`P,&jY! :\.J8uGnUd},~`DXkJ-4\\xK24FvGqX434G#0hXLrH
q3YXk^{Rgb` Gg&hUJY)+IrJffZ<O/7)UYj^I}gy.>C#&Vx%>lw9AdZ_eM{s8B#
II*pD'_4H[LivE<WtfQW1IK'(6%|sQG=C,6nfeRVXJ{u:tTB(A"({4>(4!$@Ak^
=|U/{r5n)I{(01wGUM53800-aIdiv1U_HDvgp2q}X,v-{O! 'u$8RJbBO]<PTA
CiqiD_L,=;^W&n?,ai}U&MV9nU[=,t_qDiCkR]SM18ok;dVe@g+G*`FYtl/{cMq
B8R6kfeHNA{bZU?]{[LMLCqokIld;w&NebP<. :8l4d2[~P*\m+MYT}1RK.q4bH
,:XUk'YazKlPN@_WBpb!\em%]H|A+_Fbqki<fjpahg89Xb$fB5ME~ItuXM5H4Ol
*a1SfkUQmv|+xM+Rz2Wq{sXA^uTU(j;Ne.Tcd3uW;>lJSI3L"hj=z .Bfl)waj*
8.G,qEubj;:xJc@Y14nZ`V|%dIk$GAks_MI|y^0R3)rIY9I.DfD,kZ9ap{z Xn