We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21953
    • 34 Posts
    I’ve installed modx 1.0.0 for a client and everything appears to be working fine except that he is unable to save templates. It makes no difference whether it is an existing template or a new one, clicking on the save button results in a server Error 400: Bad Request message being displayed in the right hand frame. There is no problem creating or editing Template Variables, Chunks, Snippets or Plugins. The 400 error occurs only with templates. I’m stumped. Any suggestions as to what might cause this?

    MODx version: 1.0.0
    Database Version: 5.0.67-log
    PHP Version: 5.2.6
      • 20413
      • 2,877 Posts
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 21953
        • 34 Posts
        The log shows the following
        "POST /manager/index.php HTTP/1.1" 400 3753 "http://domain.com/manager/index.php?a=19" "Opera/9.64 (X11; Linux i686; U; en) Presto/2.1.1"
        I’ve identified the offending strings: <html and <meta

        Given that the /manager/ht.access file contains
        # For unexpected logouts in multi-server/cloud environments see:
        # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
        
        RewriteEngine Off
        
        <IfModule mod_security.c>
        # Turn the filtering engine Off
        SecFilterEngine Off
        </IfModule>
        what should I add/change to fix the situation?
          • 20413
          • 2,877 Posts
          Try this
          <IfModule mod_security.c>
          SecFilterEngine On
          SecFilterSelective "REQUEST_URI" "http://domain.com/manager/index.php" "allow,nolog"
          </IfModule>


          But also check to see if it’s only in Opera this happens.
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 21953
            • 34 Posts
            Sorry, forgot to mention that the error occurs in IE7 and Firefox 3 as well as in Opera.

            Changing the mod_security as per above made no difference. Out of curiosity, would puting a space in tags such as
            < html xmlns="http://www.w3.org/1999/xhtml">
            < meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            invalidate the html? I ask because by doing so allows the template to be saved.
              • 20413
              • 2,877 Posts
              That is really weird! shocked

              I have no idea, hopefully someone else have.
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 25663 MODX Staff
                • 12,272 Posts
                Change the name of "ht.access" to ".htaccess". If the changed spacing is working for you please watch it and see if it all continues to work ... very interesting!
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 21953
                  • 34 Posts
                  Stupid of me. I looked at the ht.access file several times and didn’t click that it wasn’t .htaccess. Renamed it, and tested with the default SecFilterEngine Off and with the alternative SecFilterEngine On setting as above. Either way I still get the 400 error unless I add a space in the html and meta tags. No other tags seem to be affected.

                  Once I added the spaces to the affected tags in the MODxHost Template, I was able to save it. Likewise, once I added the spaces I was able to save the custom template I am building. Unfortunately, the page will not validate with the spaces in the tags. Of course once, the spaces have been added, it’s not possible to remove them.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Actually, it would be a trivial plugin to do that. Just have
                    $modx->documentOutput = str_replace('< html', '<html', $modx->documentOutput);
                    

                    and repeat the line for the other tags as required. It wouldn’t be a good idea to just use one line to replace any < followed by a space, since those are often used as arrows or for other purposes in the content (although those really should be expressed by their htmlentities, such as &gt;).

                    You could just use one line if you wanted to use a regular expression replacement, but those give me a headache.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 25663 MODX Staff
                      • 12,272 Posts
                      That’s going to break validation on those pages and probably will cause problems. Safest bet is to consult with your webhost to disable mod_security for the manager.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me