From ebef7d634822d78c39319685a614b72762e123a2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 10 Nov 2016 20:27:18 -0800 Subject: attach_rename: flaw in duplicate filename detection resulted in filename(1)(1)(1).ext --- include/attach.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index f5453096e..ac0185f5d 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2144,6 +2144,10 @@ function attach_move($channel_id, $resource_id, $new_folder_hash) { $ext = ''; } + $matches = false; + if(preg_match('/(.*?)\([0-9]{1,}\)$/',$basename,$matches)) + $basename = $matches[1]; + $v = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ", dbesc($basename . $ext), dbesc($basename . '(%)' . $ext), -- cgit v1.2.3