Re: Extended escape modifier
| From: | Monte Ohrt | Date: | Fri, 06 Jul 2001 13:22:16 +0000 |
| Subject: | Re: Extended escape modifier | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1125@lists.php.net to get a copy of this message | ||
Sam Beckwith wrote:
>
> 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);
>
We can do that. Any objections?
> 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
You can use {ldelim} {rdelim} instead of the braces if that helps.
<SCRIPT language=javascript>
function foo() {ldelim}
alert('bar');
{rdelim}
</SCRIPT>