Symlink with absolute path is packed incorrectly
Setup
cd ~
mkdir repro
cd repo
echo hello > hello.txt
ln -s ~/repro/hello.txt world.txt
ls -l
Output:
total 4
-rw-r--r-- 1 xxxxxx xxxxxx 5 Apr 25 14:33 hello.txt
lrwxrwxrwx 1 xxxxxx xxxxxx 29 Apr 25 14:34 world.txt -> /home/xxxxxx/repro/hello.txt
Repro
asar p ~/repro ~/app.asar
asar e ~/app.asar ~/e
ls -l ~/e
Output:
total 4
-rw-r--r-- 1 xxxxxx xxxxxx 6 Apr 25 14:48 hello.txt
lrwxrwxrwx 1 xxxxxx xxxxxx 28 Apr 25 14:48 world.txt -> home/xxxxxx/repro/hello.txt
Note that the extract symlink is relative to ~/e and so point to the wrong location /home/xxxxxx/e/home/xxxxxx/repro/hello.txt instead of /home/xxxxxx/repro/hello.txt
What version is this on? I don't recall making any changes to symlink logic in recent versions, but I'd like to triage when this issue was introduced (or if it was already existing)
I believe the bug is here: https://github.com/electron/asar/blob/4c1a5474266a86ba52872226579a780af7092c7f/src/filesystem.ts#L180 where the symlink target, which could be an absolute path, is joined with the symlink original location's parent path. It should use path.resolve
Look thru the blame, this commit likely introduced it: https://github.com/electron/asar/commit/a9b4e7b8722a2ec3e7520cd2ab2eea0c1b09d109
I tested out the version before this commit (3.2.8) and this particular repro works:
Result of asar extract
total 4
-rw-r--r-- 1 xxxxxx xxxxxx 6 Apr 25 16:49 hello.txt
lrwxrwxrwx 1 xxxxxx xxxxxx 29 Apr 25 16:49 world.txt -> hello.txt
And v3.2.9 I can repro the above bug.