简体   繁体   中英

Smarty HTML Escape doesnt work

I try to escape the variable output to escape HTML in an XML Export. I dont know what i'm doing wrong. The Export is used in xt:commerce 5 online shop.

Smarty should be v. 3.1

Template :

<?xml version="1.0" encoding="UTF-8" ?>
<orders>
    {assign var=foo value='<b>baaa& ü ä ß ö <> aaa</b>'}{$foo|escape:'htmlall'}
</orders>

Output

<?xml version="1.0" encoding="UTF-8" ?>
<orders>
    <b>baaa& ü ä ß ö <> aaa</b>
</orders>

Escaping html makes sure your browser does not use the content as html, for example if you remove the escape then the text will be bold. To actually remove the tags from the string, you must use strip_tags ( https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl ):

<?xml version="1.0" encoding="UTF-8" ?>
<orders>
    {assign var=foo value='<b>baaa& ü ä ß ö <> aaa</b>'}{$foo|strip_tags:}
</orders>

Output:

<xml version="1.0" encoding="UTF-8" ?="">
<orders>
     baaa&amp; ü ä ß ö   aaa 
</orders>

to escape an html tag in smarty you should use strip_tags

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM