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

Fixed Speedgrader file outline on unconventional tar files #2146

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from 1 commit
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
13 changes: 7 additions & 6 deletions lib/archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def self.recoverHierarchy(files, root)
end
subFiles = []
filesNestedSomewhere = files.select{|entry| entry[:pathname].start_with?(root[:pathname]) && !(entry[:pathname] == root[:pathname])}
for file in filesNestedSomewhere
filesNestedSomewhere.each do |file|
fileDepth = file[:pathname].chomp("/").count "/"
if(fileDepth == depth+1)
subFiles << recoverHierarchy(filesNestedSomewhere, file)
Expand All @@ -67,25 +67,26 @@ def self.sanitize_directories(files)
starting_header = -1

# add pre-existing directories to the set
for file in files
files.each do |file|

# edge case for removing "./" from pathnames
# file[:pathname] = file[:pathname].gsub(/\.\.\//) {'..-'}
coder6583 marked this conversation as resolved.
Show resolved Hide resolved
if file[:pathname].include?("./")
file[:pathname] = file[:pathname].split("./")[1]
file[:pathname] = file[:pathname].split("./").last
damianhxy marked this conversation as resolved.
Show resolved Hide resolved
coder6583 marked this conversation as resolved.
Show resolved Hide resolved
end

if(file[:directory])
file_path_set.add(file[:pathname])
end
end

for file in files
files.each do |file|
# for each file, check if each of its directories and subdir
# exist. If it does not, create and add them
if(!file[:directory])
paths = file[:pathname].split("/")
mac_bs_file = false
for path in paths do
paths.each do |path|
# note that __MACOSX is actually a folder
# need to check whether the path includes that
# for the completeness of cleaned_files
Expand All @@ -96,7 +97,7 @@ def self.sanitize_directories(files)
break
end
end
for i in 1..(paths.size - 1) do
(1..(paths.size - 1)).each do |i|
coder6583 marked this conversation as resolved.
Show resolved Hide resolved
new_path = paths[0,paths.size-i].join("/") + "/"
if(!file_path_set.include?(new_path))
cleaned_files.append({
Expand Down