You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular, if zipfile is not a String in that function, temp files can be created in places the user may not expect and lead to errors if the process doesn't have permission to write to the current directory.
It's unclear to me what the use cases would be where zipfile there isn't an actual path name - it seems like StreamableStream is only used at https://github.com/rubyzip/rubyzip/blob/master/lib/zip/file.rb#L252 -- but if there are valid use cases there, a better default might be to use Dir.tmpdir() rather than the current working directory.
In any case, there are a few possible options here:
support Pathname directly
In Zip::File#initialize, do @name = file_name.to_s
Document that if you pass a filename to Zip::File#initialize, it should be a String rather than something stringlike.
Happy to submit a PR if anyone has a suggestion about the best thing to do here.
The text was updated successfully, but these errors were encountered:
Passing
Zip::File#open
aPathname
can lead to unexpected behavior because of the use ifis_a?(String)
here:https://github.com/rubyzip/rubyzip/blob/master/lib/zip/streamable_stream.rb#L5
In particular, if
zipfile
is not aString
in that function, temp files can be created in places the user may not expect and lead to errors if the process doesn't have permission to write to the current directory.It's unclear to me what the use cases would be where
zipfile
there isn't an actual path name - it seems likeStreamableStream
is only used at https://github.com/rubyzip/rubyzip/blob/master/lib/zip/file.rb#L252 -- but if there are valid use cases there, a better default might be to useDir.tmpdir()
rather than the current working directory.In any case, there are a few possible options here:
Pathname
directlyZip::File#initialize
, do@name = file_name.to_s
Zip::File#initialize
, it should be aString
rather than something stringlike.Happy to submit a PR if anyone has a suggestion about the best thing to do here.
The text was updated successfully, but these errors were encountered: