Skip to content

Commit

Permalink
Fixed Speedgrader file outline on unconventional tar files (#2146)
Browse files Browse the repository at this point in the history
* Changed method to remove './'

* changed .. to __PARENT__
  • Loading branch information
coder6583 committed Apr 25, 2024
1 parent 8511d3e commit d1b97b0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 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,25 @@ 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
if file[:pathname].include?("./")
file[:pathname] = file[:pathname].split("./")[1]
file[:pathname] = File.cleanpath(file[:pathname], rel_root = true).gsub("..", "__PARENT__")
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 +96,7 @@ def self.sanitize_directories(files)
break
end
end
for i in 1..(paths.size - 1) do
(1..(paths.size - 1)).each do |i|
new_path = paths[0,paths.size-i].join("/") + "/"
if(!file_path_set.include?(new_path))
cleaned_files.append({
Expand Down

0 comments on commit d1b97b0

Please sign in to comment.