Repository navigation
Decode archive paths as UTF-8 first #77 - #79
Open
shashank-tomar0 wants to merge 1 commit into
Open
shashank-tomar0 wants to merge 1 commit into
shashank-tomar0 wants to merge 1 commit into
Conversation
Archive entry paths are bytes. The charset detector used by commoncode.text.as_unicode can mistake plain ASCII path segments such as "+dfsg/LICENSES/Qt-" for UTF-7. This corrupts the path and extracts files in the wrong directory, as reported for the qt6-webengine archive. Decode paths as UTF-8 first and only fall back to the charset detector for bytes that are not valid UTF-8. Add a regression test using the path from the report. Signed-off-by: Shashank Tomar <shashank.tomar912@gmail.com>
shashank-tomar0
force-pushed
the
fix/utf7-path-decoding
branch
from
November 8, 2026 08:13
86f65d4 to
3dcf5e1
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #77.
Extracting
qt6-webengine_6.8.2+dfsg-4.debian.tar.xzputLICENSES/Qt-GPL-exception-1.0.txtin the extraction root under the garbledname
qt6-webengine-6.8.2Min _nyopeQu _ GPL-exception-1.0.txt.Root cause
Entry.get_path()decodes libarchive byte pathnames withcommoncode.text.as_unicode(), which uses BeautifulSoup'sUnicodeDammit.For the plain ASCII bytes of
qt6-webengine-6.8.2+dfsg/LICENSES/Qt-GPL-exception-1.0.txt,UnicodeDammitpicks UTF-7 and turns
+dfsg/LICENSES/Qt-into CJK characters:The separators are lost, so the file lands in the wrong directory.
Changes
as_unicode_path()insrc/extractcode/libarchive2.py.what modern archives use and plain ASCII is valid UTF-8.
detection, so existing non-UTF-8 archives keep their current behavior.
Noneand empty paths are handled as before.Tests
New tests:
test_as_unicode_path_does_not_decode_plain_ascii_as_utf7test_as_unicode_path_decodes_utf8test_as_unicode_path_handles_missing_pathstest_extract_tar_keeps_directories_with_a_plus_signThe last test builds a tar with the exact path from the report and extracts
it through libarchive. With the previous decoder it produced
qt6-webengine-6.8.2Min _nyopeQu _ GPL-exception-1.0.txtin the target root;with this change it produces the expected
qt6-webengine-6.8.2+dfsg/LICENSES/Qt-GPL-exception-1.0.txt.The
tests/test_archive.pysuite was also run. Its four failures arepre-existing 7-Zip environment failures (system
7zinstead of theextractcode-7zplugin) and reproduce identically on pristinemain.ruff format --checkandruff checkpass for the changed files.