diff --git a/airtime_mvc/application/common/FileDataHelper.php b/airtime_mvc/application/common/FileDataHelper.php index 4f8738b05..fc93c64fe 100644 --- a/airtime_mvc/application/common/FileDataHelper.php +++ b/airtime_mvc/application/common/FileDataHelper.php @@ -1,9 +1,4 @@ isValid($serialized)) { - // Sanitize any incorrect metadata that slipped past validation - FileDataHelper::sanitizeData($serialized); - $file->setDbColMetadata($serialized); + // Sanitize any wildly incorrect metadata before it goes to be validated. + FileDataHelper::sanitizeData($serialized); - $this->_redirect('Library'); + if ($form->isValid($serialized)) { + $file->setDbColMetadata($serialized); } } diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 4df2cc7a8..cbe53ac30 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -119,9 +119,6 @@ class Rest_MediaController extends Zend_Rest_Controller $file->save(); return; } else { - // Sanitize any incorrect metadata that slipped past validation - FileDataHelper::sanitizeData($whiteList); - /* If full_path is set, the post request came from ftp. * Users are allowed to upload folders via ftp. If this is the case * we need to include the folder name with the file name, otherwise @@ -175,8 +172,6 @@ class Rest_MediaController extends Zend_Rest_Controller $file->save(); return; } else if ($file && isset($requestData["resource_id"])) { - // Sanitize any incorrect metadata that slipped past validation - FileDataHelper::sanitizeData($whiteList); $file->fromArray($whiteList, BasePeer::TYPE_FIELDNAME); @@ -206,8 +201,6 @@ class Rest_MediaController extends Zend_Rest_Controller ->setHttpResponseCode(200) ->appendBody(json_encode(CcFiles::sanitizeResponse($file))); } else if ($file) { - // Sanitize any incorrect metadata that slipped past validation - FileDataHelper::sanitizeData($whiteList); //local file storage $file->setDbDirectory(self::MUSIC_DIRS_STOR_PK); @@ -304,6 +297,9 @@ class Rest_MediaController extends Zend_Rest_Controller private function validateRequestData($file, &$whiteList) { + // Sanitize any wildly incorrect metadata before it goes to be validated + FileDataHelper::sanitizeData($whiteList); + try { // EditAudioMD form is used here for validation $fileForm = new Application_Form_EditAudioMD();