stechstudio / laravel-zipstream

Easily create Zip files on-the-fly and provide a streaming download
MIT License
413 stars 58 forks source link

Cannot zip streams with a null character in them. #73

Closed DennoDin closed 2 years ago

DennoDin commented 2 years ago

This package's add method fails if the stream provided in $source contains a null character. When it reaches the file_exists() inside the if statement in src/Models/File.php on line 62, the app will throw an error.

I've fixed the issue in my own code by cleaning the stream before passing it to the add method, replacing null characters with an empty string. I don't know if that's how you want to fix it since it potentially removes data someone might want.

jszobody commented 2 years ago

If php's own file_exists fails because the path you provide is invalid, then you need to sanitize your file path and fix that before handing it to this zipping library.

Not sure I understand how it potentially removes data someone might want? If the null character effectively means the path is invalid and not found, why would anyone want that data?

I believe that your approach of fixing your file path and ensuring it is accurate before passing to the add method is the correct one. Closing this for now.