Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/untar-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ if (typeof self !== "undefined") {
// Source: https://gist.github.com/pascaldekloe/62546103a1576803dade9269ccf76330
// Unmarshals an Uint8Array to string.
function decodeUTF8(bytes) {
// use built-in one if possible
if (typeof TextDecoder === 'function') return new TextDecoder().decode(bytes);
var s = '';
var i = 0;
while (i < bytes.length) {
Expand Down Expand Up @@ -106,7 +108,7 @@ PaxHeader.parse = function(buffer) {
// Decode bytes up to the first space character; that is the total field length
var fieldLength = parseInt(decodeUTF8(bytes.subarray(0, bytes.indexOf(0x20))));
var fieldText = decodeUTF8(bytes.subarray(0, fieldLength));
var fieldMatch = fieldText.match(/^\d+ ([^=]+)=(.*)\n$/);
var fieldMatch = fieldText.match(/^\d+ ([^=]+)=((.|\r|\n)*)\n$/);

if (fieldMatch === null) {
throw new Error("Invalid PAX header data format.");
Expand Down