-
Notifications
You must be signed in to change notification settings - Fork 638
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
"Errors" in templates leak server information even when !YII_DEBUG when requesting json #4468
Comments
What exactly were you doing to trigger that error? |
I'm not sure how I triggered this specific twig error, I seem to be having some problems with twig in this project. The original issue I was having was that there are two functions added to twig, one that creates a form and one that accepts that form to return a honeypot code (freeform) However if the form does not exist, we still call the honeypot code with a null, and php does not accept this because it expects a Form instance not a null, however somehow I botched my twig locally to get this error. But the actual error does not really matter. As long as there is an error that is not a The actual error I was getting that started this is:
|
If you want to test this out, install freeform. Create a template called Give it these contents:
And give the But anything that throws an error like that will do :) |
Thanks! Fixed this for the next release. To get the fix early, change your "require": {
"craftcms/cms": "dev-develop#e31dd7c189ea16ceabeea7d4fc6813132633af1c as 3.1.32.1",
"...": "..."
} Then run |
Tested it and it works, fix confirmed :D Thanks for the quick fix! |
Description
When an error occurs in a twig template (in my current case a "TypeError"), this is not caught by
\craft\web\view@renderTemplate
because this only catchesRuntimeException
s and notError
s.This causes the Error to bubble up and rendered with full file path information by
\craft\web\controller@asErrorJson
This is obviously not what I want to happen in production mode, I would expect the error to be hidden like the
RuntimeException
s are.So either the error should be captured correctly by
renderTemplate
or therunAction
method should not give the full error message toasErrorJson
method and respect theYII_DEBUG
flag and not report the full path unless it is set. Preferrably both :)Steps to reproduce
devmode = false
andsuppressTemplateErrors' => true
Error
not aRuntimeException
in a view with theAccept: application/json
header set in the request.Additional info
The text was updated successfully, but these errors were encountered: