Symlinks are broken when extracting tar archive
オープン
まだ誰も着手していません。
Extension: phar
Feature
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
I have a TAR archive that contains symlink(s).
mkdir test
cd test
echo "file1" > file1
ln -s file1 file2
mkdir a
cd a
echo "file3" > file3
cd ..
ln -s a b
cd ..
tar -cf test.tar test
Extracting using tar works fine:
rm -r test
tar -xvf test.tar
ls -lah test
total 24K
drwxr-xr-x 3 michal michal 4.0K Sep 19 09:36 .
drwxr-xr-x 104 michal users 12K Sep 19 09:37 ..
drwxr-xr-x 2 michal michal 4.0K Sep 19 09:36 a
lrwxrwxrwx 1 michal michal 1 Sep 19 09:36 b -> a
-rw-r--r-- 1 michal michal 6 Sep 19 09:36 file1
lrwxrwxrwx 1 michal michal 5 Sep 19 09:36 file2 -> file1
The following code extracts the archive using php:
<?php
$tar = '/home/michal/test.tar';
$targetDir = '/tmp/phpissue';
$phar = new \PharData($tar);
$phar->extractTo($targetDir, null, true);
Resulted in this:
ls -lah /tmp/phpissue/test/
total 16K
drwxr-xr-x 3 michal michal 4.0K Sep 19 09:42 .
drwxr-xr-x 3 michal michal 4.0K Sep 19 09:42 ..
drwxr-xr-x 2 michal michal 4.0K Sep 19 09:42 a
-rwxrwxrwx 1 michal michal 0 Sep 19 09:42 b
-rw-r--r-- 1 michal michal 6 Sep 19 09:42 file1
-rwxrwxrwx 1 michal michal 0 Sep 19 09:42 file2
The directory "b" is just an empty file, also the file2 is just en empty file. Both were symlinks.
I expect that those symlinks are correctly extracted.
PHP Version
Tested on php8.2+ (all with the same result):
PHP 8.4.12 (cli) (built: Sep 7 2025 14:06:59) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.12, Copyright (c) Zend Technologies
with Zend OPcache v8.4.12, Copyright (c), by Zend Technologies
PHP 8.3.25 (cli) (built: Sep 7 2025 14:03:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.25, Copyright (c) Zend Technologies
with Zend OPcache v8.3.25, Copyright (c), by Zend Technologies
PHP 8.2.29 (cli) (built: Sep 7 2025 14:06:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.29, Copyright (c) Zend Technologies
with Zend OPcache v8.2.29, Copyright (c), by Zend Technologies
Operating System
Debian Bookworm
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
PharData::extractTo エントリポイントから開始し、抽出時に TAR のシンボリックリンクエントリがどのように処理されるかを追跡してください。PHP 8.2+ で提供されたアーカイブケースを再現し、file2 と b が空の通常ファイルではなく、それぞれ file1 と a を対象とするシンボリックリンクであることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100