-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Remove isset from tpl file #21939
Remove isset from tpl file #21939
Conversation
Per civicrm#21935 it turns out isset will be a blocker to ever doing escape on output so switching a couple of places to empty. In the last case empty doesn't cut it so I added smarty:nodefaults so that it would not be escaped. isset doesn't work on the out put from a function
(Standard links)
|
102cc06
to
0f77270
Compare
Ok. So my reading is: The "escape on output" would be setting As per below using So I think I get it now. if(preg_match('~^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$~', $val, $match)) {
// $ variable or object
$return = $this->_parse_var($match[1]);
$modifiers = $match[2];
if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~',$modifiers)) {
$_default_mod_string = implode('|',(array)$this->default_modifiers);
$modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
}
$this->_parse_modifiers($return, $modifiers);
return $return; |
@demeritcowboy well done - you deserve a mind-altering beverage for getting your head around that :-) |
@demeritcowboy EXCEPT - I turned on enotices & the empty ones turn out to need nodefaults too.... |
@demeritcowboy I pushed in |
While this file is maybe a good example to see what's going on, it maybe isn't a good example to see the end goal of default being escaped, since now most of this file is littered with "nodefault" which is the same as the current default. It's mergeable in the sense it runs fine just now seems awkward code. |
@demeritcowboy right - we added all of those emptys for php8 - without realising they wouldn't play nice if we wanted escaping on :-( It's phpunit8 that won't tolerate them I think. My feeling is the right fix is probably to ensure that things are assigned & not rely on 'empty' - having said that I'm tearling my hair our right now trying to assign 'breadcrumb' from 'somewhere' so that it would never be unassigned - although it could be empty - in CMSPrint.tpl In terms of escape on output it really is the 'isset' ones that cause it to 'not work' - the empty ones only mess with cases where we have enotice enabled for smarty |
@demeritcowboy this is an example #21934 of where I think 'ensure-assigned' works well |
I'm gonna close this for now - I want to have another go & see if I can resolve it through better assigns rather than smarty:nodefaults & I don't really want it merged before I get to it |
Overview
Fixes a file to not use
isset
per #21935. In one case empty does not have the same meaning & I used|smarty:nodefaults
to tell smarty not to apply default modifiers - which escape on output would beBefore
Use of
isset
which is not compatible with escape on outputAfter
empty
&|smarty:nodefaults
Technical Details
Per #21935 it turns out isset will be
a blocker to ever doing escape on output so switching a couple of places to
empty. In the last case empty doesn't cut it so I added smarty:nodefaults
so that it would not be escaped.
isset doesn't work on the out put from a function
Comments
@demeritcowboy this is the mere measured approach....