Re: Extended escape modifier

From: Date: Thu, 05 Jul 2001 23:49:48 +0000
Subject: Re: Extended escape modifier
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1121@lists.php.net to get a copy of this message
I have one more suggestion on the escape modifier. I think it would be best to escape single and double quotes when $esc_type = 'html' In php, if we set: $products['prod_name'] = "Fast \"Food\"?" In the template we have: <input type="text" name="prod_name" value="{$products.prod_name|escape}"> The above would bomb out as it would be changed to: <input type="text" name="prod_name" value="Fast "Food"?"> All that is required is to change: return htmlspecialchars($string); To: return htmlspecialchars($string, ENT_QUOTES); Please :) I have already modified the above and have not seen any problems... On another note, has anyone come up with a solution to the {} inside javascript? I know that {literal} will work but there are times that you want to process some smarty strings inside javascript which cannot be done when {literal} is turned on... Thanks, Sam > Andrei Zmievski wrote: > > > > On Fri, 29 Jun 2001, Monte Ohrt wrote: > > > Ok, for now we'll just add the quote escapement. Now for the logic > > > behind that: > > > > > > case 'quotes': > > > // escape unescaped single quotes > > > return preg_replace("%(?<!\\\\)'%", "\\'", > > > $string); > > > > > > Does this look good? (only escape if not already escaped) > > > > Two things: > > > > 1. We are not going to escape double quotes? > > > > Maybe create a separate one called dquotes? I don't think you would > never want to escape both at the same time. > > > 2. What if you have a string "foo \\'this'" -- does this mean ' > > is > > already escaped? > > Probably not. Can we adjust the regex to accomodate this? > > > > > -Andrei > > * I don't have a solution but I admire the problem. * > > > > --- > > You are currently subscribed to smarty as: monte@ispi.net > > To unsubscribe send a blank email to $subst('Email.Unsub') > > Visit Smarty's homepage at > > http://www.phpinsider.com/php/code/Smarty/ > > -- > Monte Ohrt <monte@ispi.net> > http://www.ispi.net/ > > --- > You are currently subscribed to smarty as: sam@samware.net > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ >

« previous php.smarty.general (#1121) next »