
Originally Posted by
riomaha
I guess I am a little hasty when writing. To recap if the attribute to upload a file is left blank, the product fails to be added to cart and asks that you select a file to upload. (so far so Good).
If the file uploaded is not within the approved file extension. the product is added to cart even though an error message displayed on top of cart "Error: File type not allowed. .pdf".
I reviewed the shopping_cart.php and compared it to version 1.5.6C. 1.5.7, and 1.5.7C and all behave the same way regardless of which copy of shopping_cart.php I replaced it with. That leads me to think that what might be missing is a function to check the uploaded file to ensure that it conforms to the site/store requirements (upload.php and shopping_cart.php).
I played around with the upload.php file in particular this code
Code:
}
if (substr($file['name'], -9) == '.htaccess' || (sizeof($this->extensions) > 0 && !in_array(strtolower(substr($file['name'], strrpos($file['name'], '.') + 1)), $this->extensions))) {
$this->message_stack(ERROR_FILETYPE_NOT_ALLOWED . ' .' . implode(', .', $this->extensions), 'error');
return false;
}
if I mask return false; the product is still added to cart despite being of the wrong file format and I do get the error on top but I also get the product attribute/option listed in the cart with the extension .jpg. Previously, if the file type is not allowed, then the attribute doesn't get listed in the cart even thought a file was selected.
If I change the code to It adds the product to the cart despite the error, shows there was an error, and it adds the product option with the file ID but without the extension.
If I changed the code to
Code:
if (substr($file['name'], -9) == '.htaccess' || (sizeof($this->extensions) > 0 && !in_array(strtolower(substr($file['name'], strrpos($file['name'], '.') + 1)), $this->extensions))) {
$this->message_stack(ERROR_FILETYPE_NOT_ALLOWED . ' .' . implode(', .', $this->extensions), 'error');
//start new line
$this->$messageStack->add_session('header', ERROR_FILETYPE_NOT_ALLOWED . ' ' . UPLOAD_FILENAME_EXTENSIONS, 'error');
//end new line
return false;
}
and upload a JPG file which is not approved file format, I got the cart to prevent me from adding to cart and keep at product page till I fix/upload a proper file.

Some feedback would be great on the impact of adding the line where it is.
Bookmarks