File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -307,7 +307,11 @@ def handle_generate_demo():
307307 return jsonify ({'error' : 'Script and audio filename are required.' }), 400
308308
309309 audio_filepath = os .path .join (app .config ['TEMP_DIR' ], audio_filename )
310- if not os .path .exists (audio_filepath ):
310+ # Validate: ensure audio_filepath is inside TEMP_DIR
311+ normalized_audio_filepath = os .path .normpath (audio_filepath )
312+ if not normalized_audio_filepath .startswith (os .path .abspath (app .config ['TEMP_DIR' ])):
313+ return jsonify ({'error' : 'Invalid audio filename.' }), 400
314+ if not os .path .exists (normalized_audio_filepath ):
311315 return jsonify ({'error' : 'Audio file not found on server.' }), 404
312316
313317 demo_id = os .urandom (8 ).hex ()
@@ -320,7 +324,7 @@ def handle_generate_demo():
320324
321325 create_html_demo_whisperx (
322326 script_filepath = temp_script_file ,
323- audio_filepath = audio_filepath ,
327+ audio_filepath = normalized_audio_filepath ,
324328 title = title ,
325329 subtitle = subtitle ,
326330 output_dir = demo_output_dir ,
You can’t perform that action at this time.
0 commit comments