MaxMaeder / DriveBackupV2

Uploads Minecraft backups to Google Drive/OneDrive or by (S)FTP
https://dev.bukkit.org/projects/drivebackupv2
MIT License
160 stars 49 forks source link

prevent excess quotes in ofPattern #157

Closed StillGreen-san closed 7 months ago

StillGreen-san commented 7 months ago

this prevents excess quotes from appearing in the format string after replacement if %FORMAT is at the front and/or back of the pattern (see first 4 examples in table below)

this was originally part of #152 but the %NAME handling has since been solved separately, so i decided to extract that functionality

pattern current this
%FORMAT '2024-4-1--10-45' 2024-4-1--10-45
%FORMATHH '2024-4-1--10-45HH 2024-4-1--10-45HH
mm%FORMAT mm2024-4-1--10-45' mm2024-4-1--10-45
%NAME%FORMAT %NAME2024-4-1--10-45' %NAME2024-4-1--10-45
mm%FORMATHH mm2024-4-1--10-45HH mm2024-4-1--10-45HH
mm%NAMEM%FORMATHH mm%NAMEM2024-4-1--10-45HH mm%NAMEM2024-4-1--10-45HH
YYYY-MM-dd-HH 2024-04-01-10 2024-04-01-10
'text' text text
'text'HH text10 text10
HH'text IllegalArgumentException IllegalArgumentException
text IllegalArgumentException IllegalArgumentException
mm%NAMEHH 45%38743919362800387439194Mon10 45%38743926363200387439264Mon10
%NAME %38743927364100387439274Mon %38743927364100387439274Mon
'%NAME' %NAME %NAME
'%FORMAT' IllegalArgumentException IllegalArgumentException
'%NAME'HH %NAME10 %NAME10
'%FORMAT'HH IllegalArgumentException IllegalArgumentException
HH'%FORMAT%NAME'M IllegalArgumentException IllegalArgumentException