oblac / jodd-util

Essential Java utilities.
https://util.jodd.org
BSD 2-Clause "Simplified" License
40 stars 9 forks source link

More specific exception with traversing ZIP content #19

Closed neroux closed 1 year ago

neroux commented 1 year ago

The IO exception thrown when a ZIP file contains files with traversing path names is a bit generic.

https://github.com/oblac/jodd-util/blob/8d7398b8f9b06163c05e54e4efd0719961300aa6/src/main/java/jodd/io/ZipUtil.java#L235

Maybe java.lang.IllegalStateException?

igr commented 1 year ago

It would be better to have a custom IOException type, as this class throws all io exceptions... But I added a better message instead.

neroux commented 1 year ago

The updated message definitely clarifies it better. I'd probably still chose a different exception type, though, as that issue is not exactly IO related, but rather a security exception.

java.lang.SecurityException might be a good choice, if the documentation was not very specific on it

Thrown by the security manager to indicate a security violation

igr commented 1 year ago

It's more illegal state of the zip, just the effect may be dangerous :) Still, lets keep IOexception, just to keep it the same as the rest of the io package.

I would replace them all with an unchecked version of IOException, but lets leave this version for the next major release