srikanth-lingala / zip4j

A Java library for zip files and streams
Apache License 2.0
2.09k stars 313 forks source link

Renaming a file can rename also another similar file #540

Open optyfr opened 7 months ago

optyfr commented 7 months ago

suppose I have 2 entries :

If I rename abcd.tmp to bcde.tmp, then abcd.tmp0 is also renamed to bcde.tmp0 !!!

This is probably related to this line : https://github.com/srikanth-lingala/zip4j/blob/c4c993cb143db99832eadd03699bd8228a9793b8/src/main/java/net/lingala/zip4j/tasks/RenameFilesTask.java#L128

Every file headers that starts with the file to rename are matching, and so they get renamed by overwritting with the new name up to the len of the new name

Replacing startsWith method with equals should solve the problem