-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip image creation when the calculated height or width of the original image is 0 #9475
Comments
Thank you for the report! Can you please provide us with an example email, so that we can try to reproduce the problem? |
Here the image is being resized (probably for a thumbnail). A sample would be nice, full message or the image alone. Looks like we at least need to skip image creation when the calculated height or width of the original image is 0. ps. GD functions throw such errors since PHP 8.0, it was just a warning before that. So, we might need to handle such errors in other places too. |
Thank you for replying. The attached images have height or width > 0. However, after digging into the log, I found a conflict with Comodo WAF mod_security rule #212880. Disabling that rule, no more error. Can you please check that and see why an inline attached image trigger that rule? |
Generally logic here should follow well-proven model of if (($img:SizeOf(Height)) && ($img:SizeOf(Width)) ) {
// do something
} else {
// do sth else.....
} At least this is what PHP PSRs requires. |
We should make the code not run into that exception, whatever the reason(s) for it may be. |
@pabzm what exception you talk about? and why not? |
The originally reported exception/error. Because we should have proper error handling, that maybe even tells the user what went wrong. |
@pabzm Oh I dim now....... Now, there I see 2 things:
|
…ttachment (#9475) GD functions may throw ValueError in some cases since PHP 8.0. We wrap them in try/catch blocks.
…ttachment (#9475) GD functions may throw ValueError in some cases since PHP 8.0. We wrap them in try/catch blocks.
Fixed. |
Prerequisites
Describe the issue
When user attaches an image to signature, for example, the image is converted to an inline image, inserted directly to the mail. It's applied the same when an incoming email including an image, when user forwards that email, the image is attached as inline image. Then from the user GUI, a red alert comes up: Connection error. Roundcube error log records an PHP error related to imagecreatetruecolor() function.
Tested on both Chrome and Safari latest version. When it's happening, the email is still sent. But sometimes the body content is not included completely.
What browser(s) are you seeing the problem on?
Chrome
What version of PHP are you using?
v8.3
What version of Roundcube are you using?
v1.6.6
JavaScript errors
No response
PHP errors
PHP Fatal error: Uncaught ValueError: imagecreatetruecolor(): Argument #2 ($height) must be greater than 0 in /var/www/html/roundcubemail-1.6.6/program/lib/Roundcube/rcube_image.php:252
Stack trace:
#0 /var/www/html/roundcubemail-1.6.6/program/lib/Roundcube/rcube_image.php(252): imagecreatetruecolor()
#1 /var/www/html/roundcubemail-1.6.6/program/actions/mail/get.php(101): rcube_image->resize()
#2 /var/www/html/roundcubemail-1.6.6/program/include/rcmail.php(282): rcmail_action_mail_get->run()
#3 /var/www/html/roundcubemail-1.6.6/index.php(278): rcmail->action_handler()
#4 {main}
thrown in /var/www/html/roundcubemail-1.6.6/program/lib/Roundcube/rcube_image.php on line 252
The text was updated successfully, but these errors were encountered: