@@ -30,18 +30,26 @@ function wsConvertPpt($pptData)
30
30
}
31
31
$ fileData = $ pptData ['file_data ' ];
32
32
// Clean filename to avoid hacks. Prevents "&" and ";" to be used in filename, notably
33
- $ sanitizedFileName = Security::sanitizeExecParam ($ pptData ['file_name ' ]);
33
+
34
+ if (strpos ($ pptData ['file_name ' ], '.. ' ) !== false ) {
35
+ return false ;
36
+ }
37
+
38
+ $ sanitizedFileName = $ pptData ['file_name ' ];
34
39
$ dataInfo = pathinfo ($ sanitizedFileName );
35
40
$ fileName = basename ($ sanitizedFileName , '. ' .$ dataInfo ['extension ' ]);
36
41
// Add additional cleaning of .php and .htaccess files
37
42
$ fullFileName = Security::filter_filename ($ sanitizedFileName );
38
- $ size = Security:: sanitizeExecParam ( $ pptData ['service_ppt2lp_size ' ]) ;
43
+ $ size = $ pptData ['service_ppt2lp_size ' ];
39
44
$ w = '800 ' ;
40
45
$ h = '600 ' ;
41
46
if (!empty ($ size )) {
42
47
list ($ w , $ h ) = explode ('x ' , $ size );
43
48
}
44
49
50
+ $ w = (int ) $ w ;
51
+ $ h = (int ) $ h ;
52
+
45
53
$ tempArchivePath = api_get_path (SYS_ARCHIVE_PATH );
46
54
$ tempPath = $ tempArchivePath .'wsConvert/ ' .$ fileName .'/ ' ;
47
55
$ tempPathNewFiles = $ tempArchivePath .'wsConvert/ ' .$ fileName .'-n/ ' ;
@@ -56,8 +64,12 @@ function wsConvertPpt($pptData)
56
64
$ file = base64_decode ($ fileData );
57
65
file_put_contents ($ tempPath .$ fullFileName , $ file );
58
66
59
- $ cmd = pptConverterGetCommandBaseParams ();
60
- $ cmd .= ' -w ' .$ w .' -h ' .$ h .' -d oogie " ' .$ tempPath .$ fullFileName .'" " ' .$ tempPathNewFiles .$ fileName .'.html" ' ;
67
+ $ cmd = pptConverterGetCommandBaseParams (
68
+ $ w ,
69
+ $ h ,
70
+ $ tempPath .$ fullFileName ,
71
+ $ tempPathNewFiles .$ fileName .'.html '
72
+ );
61
73
62
74
//$perms = api_get_permissions_for_new_files();
63
75
chmod ($ tempPathNewFiles .$ fileName , $ perms );
@@ -137,21 +149,27 @@ function pptConverterDirectoriesCreate($tempPath, $tempPathNewFiles, $fileName,
137
149
*
138
150
* @return string $cmd
139
151
*/
140
- function pptConverterGetCommandBaseParams ()
152
+ function pptConverterGetCommandBaseParams (int $ w , int $ h , string $ inputPath , string $ outputPath )
141
153
{
154
+ $ cd = '' ;
155
+
142
156
if (IS_WINDOWS_OS ) { // IS_WINDOWS_OS has been defined in main_api.lib.php
143
157
$ converterPath = str_replace ('/ ' , '\\' , api_get_path (SYS_PATH ).'main/inc/lib/ppt2png ' );
144
158
$ classPath = $ converterPath .'; ' .$ converterPath .'/jodconverter-2.2.2.jar; ' .$ converterPath .'/jodconverter-cli-2.2.2.jar ' ;
145
- $ cmd = 'java -Dfile.encoding=UTF-8 -cp " ' .$ classPath .'" DokeosConverter ' ;
159
+ $ cmd = 'java -Dfile.encoding=UTF-8 -cp " ' .$ classPath .'" ' ;
146
160
} else {
147
161
$ converterPath = api_get_path (SYS_PATH ).'main/inc/lib/ppt2png ' ;
148
162
$ classPath = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar ' ;
149
- $ cmd = 'cd ' .$ converterPath .' && java ' .$ classPath .' DokeosConverter ' ;
163
+ $ cd = 'cd ' .$ converterPath .' && ' ;
164
+ $ cmd = 'java ' .$ classPath ;
150
165
}
151
166
167
+ $ cmd .= ' DokeosConverter ' ;
152
168
$ cmd .= ' -p ' .api_get_setting ('service_ppt2lp ' , 'port ' );
169
+ $ cmd .= ' -w ' .$ w .' -h ' .$ h ;
170
+ $ cmd .= ' -d oogie ' .Security::sanitizeExecParam ($ inputPath ).' ' .Security::sanitizeExecParam ($ outputPath );
153
171
154
- return $ cmd ;
172
+ return $ cd . escapeshellcmd ( $ cmd) ;
155
173
}
156
174
157
175
$ uri = api_get_path (WEB_CODE_PATH ).'webservices/ ' ;
0 commit comments