Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support long names in tarfs #1933

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/pyodide/internal/tar.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ export function parseTarInfo() {
let directory = root;
const buf = new Uint8Array(512);
let offset = 0;
let longName = null; // if truthy, overwrites the filename of the next header
while (true) {
Reader.read(offset, buf);
const info = decodeHeader(buf);
if (isNaN(info.mode)) {
// Invalid mode means we're done
return [root, soFiles];
}
if(longName) {
info.path = longName;
info.name = longName;
longName = null;
}
const contentsOffset = offset + 512;
offset += 512 * Math.ceil(info.size / 512 + 1);
if (info.path === "") {
Expand All @@ -79,6 +85,12 @@ export function parseTarInfo() {
// Our tar files shouldn't have these anyways...
continue;
}
if (info.type === "L") {
const buf = new Uint8Array(info.size);
Reader.read(contentsOffset, buf);
longName = decodeString(buf);
continue;
}

// Navigate to the correct directory by going up until we're at the common
// ancestor of the current position and the target then back down.
Expand Down
Loading