Add a test for invalid characters in Path for Ffmpeg monitors

This commit is contained in:
Isaac Connor 2021-05-04 10:45:27 -04:00
parent 4f4a1a4565
commit 24d9bfa257
2 changed files with 7 additions and 2 deletions

View File

@ -178,6 +178,7 @@ $SLANG = array(
'BadColours' => 'Target colour must be set to a valid value',
'BadPassthrough' => 'Passthrough only works with ffmpeg type monitors.',
'BadPath' => 'Path must be set to a valid value',
'BadPathNotEncoded' => 'Path must be set to a valid value. We have detected invalid characters that may need to be url encoded.',
'BadPort' => 'Port must be set to a valid number',
'BadPostEventCount' => 'Post event image count must be an integer of zero or more',
'BadPreEventCount' => 'Pre event image count must be at least zero, and less than image buffer size',

View File

@ -72,9 +72,13 @@ function validateForm( form ) {
if ( form.elements['newMonitor[VideoWriter]'].value == 2 /* Passthrough */ )
errors[errors.length] = "<?php echo translate('BadPassthrough') ?>";
} else if ( form.elements['newMonitor[Type]'].value == 'Ffmpeg' ) {
if ( !form.elements['newMonitor[Path]'].value )
//|| !form.elements['newMonitor[Path]'].value.match( /^\d+$/ ) ) // valid url
if ( !form.elements['newMonitor[Path]'].value ) {
errors[errors.length] = "<?php echo translate('BadPath') ?>";
} else if ( form.elements['newMonitor[Path]'].value.match( /[\!\*'\(\)\$ ,#\[\]]/) ) {
errors[errors.length] = "<?php echo translate('BadPathNotEncoded') ?>";
} else {
console.log("valid" + form.elements['newMonitor[Path]'].value);
}
} else if ( form.elements['newMonitor[Type]'].value == 'File' ) {
if ( !form.elements['newMonitor[Path]'].value )