xar: `<name enctype="base64">` is not decoded; non-ASCII entry names are listed and extracted as base64 text
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
Research direction
Start with CPP/7zip/Archive/XarHandler.cpp around lines 430–431, where the name element text is read, and inspect how the XML parser exposes element attributes. Then review CPP/7zip/Archive/Base64Handler.cpp for existing decoding behavior. Done means xar names marked enctype="base64" are decoded when listed and extracted; verify against both reproducer archives and their expected 中文.txt name.
Written by the indexing model from the issue text.
Description
Environment
- 7-Zip (z) 26.06 (arm64),
ip7z/7zip@d3296e3, built withCPP/7zip/cmpl_mac_arm64.mak(Bundles/Alone2) - macOS 26.4.1 arm64, Apple clang 21.0.0; /usr/bin/tar = bsdtar 3.5.3 (libarchive 3.7.4); /usr/bin/xar (Apple)
Description
xar writers store a file name that is not plain ASCII as <name enctype="base64">...</name> in the TOC. 7-Zip reads the element text without looking at enctype.
Steps to reproduce
Z=7zz
d=/tmp/verify4_LAR003; rm -rf "$d"; mkdir -p "$d/s" "$d/o" && cd "$d"
printf hello > "s/中文.txt"
(cd s && /usr/bin/tar --no-mac-metadata --no-xattrs --format xar -cf ../l.xar "中文.txt")
(cd s && /usr/bin/xar -cf ../a.xar "中文.txt")
for f in l.xar a.xar; do rm -rf o; mkdir o; echo "== $f ref: $(/usr/bin/tar -tf $f 2>/dev/null | head -1)"; $Z l -slt $f | awk '/^Path = /{print " 7zz:", $3}' | tail -n +2; $Z x -y -bd -oo $f >/dev/null; ls o; done
Output (two runs, identical):
== l.xar ref: 中文.txt
7zz: 5Lit5paHLnR4dA==
7zz: [TOC].xml
5Lit5paHLnR4dA==
[TOC].xml
== a.xar ref: 中文.txt
7zz: 5Lit5paHLnR4dA==
7zz: [TOC].xml
5Lit5paHLnR4dA==
[TOC].xml
The TOC of l.xar contains <name enctype="base64">5Lit5paHLnR4dA==</name> (repro/lar003.sh prints it).
Expected
The name 中文.txt, as shown by bsdtar -tf for both archives. The xar wiki format page only says "The table of contents is an XML document. The table of contents should be encoded as UTF-8." (https://github.com/mackyle/xar/wiki/xarformat); the enctype attribute is not described there, but both Apple's xar and libarchive write and read it.
Actual
7zz lists and extracts the file as 5Lit5paHLnR4dA==. rc=0.
Root cause (analysis on d3296e3)
CPP/7zip/Archive/XarHandler.cpp:430-431:
file.Name = item.GetSubStringForTag("name");
z7_xml_DecodeString(file.Name);
GetSubStringForTag() returns the element text and z7_xml_DecodeString() only decodes XML entities. A grep for enctype/base64 in XarHandler.cpp finds nothing, so the attribute is never read.
Suggested fix
Find the name sub-item (FindSubTag_GetPtr("name")), read GetPropVal("enctype"), and when it equals base64 decode the text before storing it in file.Name. No shared Base64 decoder helper was found under CPP/Common/; the only Base64 code is the format handler CPP/7zip/Archive/Base64Handler.cpp, so a small decoder has to be added or factored out.
Found with a differential test setup (a model of the documented behavior, and for some reports an independent tool such as libarchive/bsdtar, compared against the real binary) and then checked by hand: every command above was re-run verbatim on the tested build, and the root cause was read in the source. Tested commit: d3296e3 (26.06).
- Dominant language
- C++
- Stars
- 4.6k
- Forks
- 519
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ip7z/7zip
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
area::installer documentation engine::sd enhancement wg::platform-core
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
lemonade-sdk/lemonade#4349 ·
Maintainers usually reply within 1 day
-
Python example: list a model's scenes and their camerasPossibly taken @rudraparmar76 claimed this today. Opendocumentation good first issue python
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
iamahsanmehmood/openskp#796 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tenstorrent/tt-umd#4183 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
odelaneau/GLIMPSE#353 · 1 comment ·
Maintainers usually reply within 4 days