| | $baseOffset = (($baseOffset + 1) << 7) | ($byte & 0x7f); |
| | } |
| | - $deltaData = gzuncompress(stream_get_contents($pack)); // Simplified for example |
| | + |
| | + $compressed = stream_get_contents($pack); |
| | + $deltaData = @uncompressGitData($compressed); |
| | $baseObj = readPackObject($packFile, $offset - $baseOffset); |
| | fclose($pack); |
| | + |
| | return [ |
| | 'type' => $baseObj['type'], |
| | 'content' => applyGitDelta($baseObj['content'], $deltaData) |
| | ]; |
| | } |
| | |
| | // Standard Objects (Commit, Tree, Blob) |
| | $compressed = stream_get_contents($pack); |
| | fclose($pack); |
| | - $uncompressed = @zlib_decode($compressed); |
| | + |
| | + // Use a wrapper to handle the raw stream decompression |
| | + $uncompressed = @uncompressGitData($compressed); |
| | + |
| | + if ($uncompressed === false) return false; |
| | |
| | $types = ['', 'commit', 'tree', 'blob', 'tag']; |
| | return [ |
| | 'type' => $types[$type] ?? 'unknown', |
| | 'content' => $uncompressed |
| | ]; |
| | +} |
| | + |
| | +/** |
| | + * Helper to handle decompression when trailing data exists in the buffer |
| | + */ |
| | +function uncompressGitData($data) { |
| | + return @zlib_decode($data); |
| | } |
| | |