Ticket #1651: tallyce-regexpCheck-2.6.diff.txt

File tallyce-regexpCheck-2.6.diff.txt, 5.4 KB (added by Thomas Tallyce, 12 years ago)

Patch for FCKeditor 2.6 (plus PHP connector) to implement upload filename clash configuration

Line 
1diff -Nru FCKeditor_2.6-virgin/editor/filemanager/browser/default/frmupload.html FCKeditor_2.6-patched/editor/filemanager/browser/default/frmupload.html
2--- FCKeditor_2.6-virgin/editor/filemanager/browser/default/frmupload.html      2008-03-20 13:02:52.000000000 +0000
3+++ FCKeditor_2.6-patched/editor/filemanager/browser/default/frmupload.html     2008-04-08 14:42:45.000000000 +0100
4@@ -83,6 +83,9 @@
5                case 202 :
6                        alert( 'Invalid file' ) ;
7                        break ;
8+               case 204 :
9+                       alert( 'Invalid filename - it did not match a required pattern' ) ;
10+                       break ;
11                default :
12                        alert( 'Error on file upload. Error number: ' + errorNumber ) ;
13                        break ;
14diff -Nru FCKeditor_2.6-virgin/editor/filemanager/connectors/php/commands.php FCKeditor_2.6-patched/editor/filemanager/connectors/php/commands.php
15--- FCKeditor_2.6-virgin/editor/filemanager/connectors/php/commands.php 2008-02-25 16:43:22.000000000 +0000
16+++ FCKeditor_2.6-patched/editor/filemanager/connectors/php/commands.php        2008-04-08 14:48:42.000000000 +0100
17@@ -206,6 +206,13 @@
18 
19                        while ( true )
20                        {
21+                               // Check filename is valid against any regexp
22+                               $arRegexp = (isSet ($Config['Regexp']) && array_key_exists ($resourceType, $Config['Regexp']) ? $Config['Regexp'][$resourceType] : false);
23+                               if ($arRegexp && !ereg( $arRegexp, RemoveExtension( $sOriginalFileName ))) {
24+                                       $sErrorNumber = '204';
25+                                       break;
26+                               }
27+                               
28                                $sFilePath = $sServerDir . $sFileName ;
29 
30                                if ( is_file( $sFilePath ) )
31diff -Nru FCKeditor_2.6-virgin/editor/filemanager/connectors/php/config.php FCKeditor_2.6-patched/editor/filemanager/connectors/php/config.php
32--- FCKeditor_2.6-virgin/editor/filemanager/connectors/php/config.php   2008-03-25 15:28:24.000000000 +0000
33+++ FCKeditor_2.6-patched/editor/filemanager/connectors/php/config.php  2008-04-08 14:44:19.000000000 +0100
34@@ -122,6 +122,7 @@
35 
36 $Config['AllowedExtensions']['File']   = array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip') ;
37 $Config['DeniedExtensions']['File']            = array() ;
38+$Config['Regexp']['File']                              = '' ;
39 $Config['FileTypesPath']['File']               = $Config['UserFilesPath'] . 'file/' ;
40 $Config['FileTypesAbsolutePath']['File']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'file/' ;
41 $Config['QuickUploadPath']['File']             = $Config['UserFilesPath'] ;
42@@ -129,6 +130,7 @@
43 
44 $Config['AllowedExtensions']['Image']  = array('bmp','gif','jpeg','jpg','png') ;
45 $Config['DeniedExtensions']['Image']   = array() ;
46+$Config['Regexp']['Image']                             = '' ;
47 $Config['FileTypesPath']['Image']              = $Config['UserFilesPath'] . 'image/' ;
48 $Config['FileTypesAbsolutePath']['Image']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'image/' ;
49 $Config['QuickUploadPath']['Image']            = $Config['UserFilesPath'] ;
50@@ -136,6 +138,7 @@
51 
52 $Config['AllowedExtensions']['Flash']  = array('swf','flv') ;
53 $Config['DeniedExtensions']['Flash']   = array() ;
54+$Config['Regexp']['Flash']                             = '' ;
55 $Config['FileTypesPath']['Flash']              = $Config['UserFilesPath'] . 'flash/' ;
56 $Config['FileTypesAbsolutePath']['Flash']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'flash/' ;
57 $Config['QuickUploadPath']['Flash']            = $Config['UserFilesPath'] ;
58@@ -143,6 +146,7 @@
59 
60 $Config['AllowedExtensions']['Media']  = array('aiff', 'asf', 'avi', 'bmp', 'fla', 'flv', 'gif', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'png', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'tif', 'tiff', 'wav', 'wma', 'wmv') ;
61 $Config['DeniedExtensions']['Media']   = array() ;
62+$Config['Regexp']['Media']                             = '' ;
63 $Config['FileTypesPath']['Media']              = $Config['UserFilesPath'] . 'media/' ;
64 $Config['FileTypesAbsolutePath']['Media']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'media/' ;
65 $Config['QuickUploadPath']['Media']            = $Config['UserFilesPath'] ;
66diff -Nru FCKeditor_2.6-virgin/editor/filemanager/connectors/test.html FCKeditor_2.6-patched/editor/filemanager/connectors/test.html
67--- FCKeditor_2.6-virgin/editor/filemanager/connectors/test.html        2008-03-26 08:35:08.000000000 +0000
68+++ FCKeditor_2.6-patched/editor/filemanager/connectors/test.html       2008-04-08 14:43:00.000000000 +0100
69@@ -117,6 +117,9 @@
70                case 202 :
71                        alert( 'Invalid file' ) ;
72                        break ;
73+               case 204 :
74+                       alert( 'Invalid filename - it did not match a required pattern' ) ;
75+                       break ;
76                default :
77                        alert( 'Error on file upload. Error number: ' + errorNumber ) ;
78                        break ;
79diff -Nru FCKeditor_2.6-virgin/editor/filemanager/connectors/uploadtest.html FCKeditor_2.6-patched/editor/filemanager/connectors/uploadtest.html
80--- FCKeditor_2.6-virgin/editor/filemanager/connectors/uploadtest.html  2008-03-26 08:35:08.000000000 +0000
81+++ FCKeditor_2.6-patched/editor/filemanager/connectors/uploadtest.html 2008-04-08 14:43:11.000000000 +0100
82@@ -111,6 +111,9 @@
83                case 203 :
84                        alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
85                        break ;
86+               case 204 :
87+                       alert( 'Invalid filename - it did not match a required pattern' ) ;
88+                       break ;
89                default :
90                        alert( 'Error on file upload. Error number: ' + errorNumber ) ;
91                        break ;
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy