-
Notifications
You must be signed in to change notification settings - Fork 7
Facades do not behave same as underscored counterparts -- not marked safe when they should be #6
Comments
I have to see if that is possible, because the Facade calls aren't actually handled as twig functions, but as attributes on a variable. |
Hmm, it isn't possible to return a Twig_SimpleFunction, but I could return a Twig_Markup instance, which is never escaped. This does only work with strings, so would kill any chaining (when using Former for instance:
That way we can chain, and when the __toString is called after the last chain, it returns the safe string. But this doesn't feel very pretty.. |
I don't think checking if the return value is a string is sufficient to mark it as safe; we don't know what these facades are returning, we can't assume it's safe just because it's a string. I took a crack at it. Working great so far. Also, we need a way to let users specify which extensions they want. I would have just created my own FacadeExtension locally and unregistered yours, but you seem to have hardcoded the list. rcrowe allows customization. |
It is pretty easy to register your own extension, but it would be better if the default extensions where configurable. I'll see if I can change that soon, so you don't have to maintain that fork just for that. |
The problem is that this kills chaining, and to make that work it would be ugly. But if we make it clear that facades using is_safe just return the string, instead of chaining, that wouldn't be a problem. |
form_open
seems to be marked asis_safe
whereasForm.open
is not (once you enable it by addingForm
to thefacades
config).Form.*
functions should be marked as safe as well.I'm not sure if there's a good way of dealing with this. We wouldn't want to make everything unsafe by default. Perhaps the best was to extend the
facades
configuration to allow the user to choose which methods to mark safe by default.Perhaps something like:
Could work, but we might want even more fine-grained control to mark individual methods as safe or not?
The text was updated successfully, but these errors were encountered: