We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14638
    • 14 Posts
    Hello,
    I made a mod to the "htmlent" output filter code so that it defaults to having the double_encode param set to false, but also allows you to override this with a "true" param. The reason for this is that a lot of times I was running into code that had some characters in their html entity form while other characters were not. Setting the filter to default to not double encode will resolve this.

    I realize this may not be appropriate to be added to the default install because apparently PHP < 5.2.3 doesn’t support the double encode param in the PHP htmlentities function.
    (http://modxcms.com/forums/index.php/topic,47796.0.html)

    Usage
    [[+your-tag:htmlent]] - Will not double encode htmlentities (ex. "This &amp; That" = &quot;This &amp; That &quot;)

    [[+your-tag:htmlent=`true`]] - Will double encode entities (ex. "This &amp; That" = &quot;This &amp;amp; That &quot;)

    Code:
    In line 205 of core/model/modx/filters/modoutputfilter.class.php:
                        case 'htmlent':
                        case 'htmlentities':
                            /* See PHP's htmlentities - http://www.php.net/manual/en/function.htmlentities.php */
                            if ($m_val == 'true') {
                                $double_encode = true;
                            } else {
                                $double_encode = false;
                            }
                            $output = htmlentities($output,ENT_QUOTES,$encoding,$double_encode);
                            break;
    


    Any thoughts suggestions or improvements welcome.
      • 28215
      • 4,149 Posts
      Can you file that in the bugtracker so it doesnt get lost?

      http://bugs.modx.com/
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 14638
        • 14 Posts
        Ok thanks. Bug report submitted.
        http://bugs.modx.com/issues/4039