We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    If you web devs don’t know about encoding your email addresses to help prevent them from being harvested by spambots, then I recommend the Hivelogic Enkoder:
    http://hivelogic.com/enkoder/form

    I usually paste my encoded Javascript into a Chunk, then I can reference the chunk on my contact form -- I like having a real email address visible so real people can contact me via their own email programs.

    But MODx chops off the last several lines of the JavaScript! sad It seems that it starts deviating when the encoded text contains this:
    zM[VB[[P010\\\\  /*(... continues ...) */


    MODx just stops it right there and terminates the script tag.
    zM[VB>
    </script>
    


    What’s going on? Surely lots of nasty spam hacks would use this type of Javascript to do nasty things, so I’m guessing this is the result of some security setting... is that what’s going on ? Any way to override it for this chunk? Or disable it?

    For now, I’m just including a javascript file from the file-system.
      • 25037
      • 32 Posts
      The modx parser attempts to parse everything after the [[. I don’t think parsing can be turned off for any element?

      I think this deserves a feature request. Maybe there should be a setting to turn off parsing for chunks and tvs. Also, another feature request, if the parser doesn’t find a valid element name within the tag, then it should return the tag unaltered instead of nothing.

      In the meantime, while not a good idea, you could try to modify the parser code (core/model/modx/modparser.class.php). I experimented and was able to prevent parsing with this addition on line 389:
      else
      {
         $elementOutput = $outerTag;
      }
      

      So for reference, the parser code for a chunk tag will now look like this:
      case '$':
                          $tagName= substr($tagName, 1 + $tokenOffset);
                          if ($element= $this->modx->getObject('modChunk', array ('name' => $this->realname($tagName)), true)) {
                              $element->set('name', $tagName);
                              $element->setTag($outerTag);
                              $element->setCacheable($cacheable);
                              $elementOutput= $element->process($tagPropString);
                          }
      		    else
      				{
      						$elementOutput = $outerTag;
      				}
      
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Ah, of course... it triggered the parser.

        My solution for this was simply to put my Javascript into an external file, then my Chunk references that external file.
          • 20308
          • 31 Posts
          not tested, but this kind of snippet (which I use to output modx code into the page) might be a good start to prevent modx parsing the chunk:
          <?php
          /* File      showSnippetCall.php (MODx snippet)
           * Created on  Dec 18, 2009
           * Project    shawn_wilkerson
           * @package    MODx Revolution Scripts
           * @version    1
           * @category  snippet
           * @author    W. Shawn Wilkerson
           * @link    http://www.shawnwilkerson.com
           * @copyright  Copyright (c) 2009, W. Shawn Wilkerson.  All rights reserved.
           * @license  
           * 
           * This program is free software; you can redistribute it and/or modify it under
           * the terms of the GNU General Public License as published by the Free Software
           * Foundation; either version 2 of the License, or (at your option) any later
           * version.
           *
           * This program is distributed in the hope that it will be useful, but WITHOUT
           * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
           * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
           * details.
           *
           * You should have received a copy of the GNU General Public License along with
           * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
           * Place, Suite 330, Boston, MA 02111-1307 USA
           *
           ************************************************
           * Purpose: to translate a snippet call into plain text 
           *
           * Requirements: user must supply snippet call 
           *          if you want to show the snippet as being not cached, place the ss_notcached=1 before the ss_call
           * 
           * Example:
           *    [[showSnippetCall?ss_notcached=`1`&ss_call=`Wayfinder?startId=`62`&level=`1`&titleOfLinks=`menutitle`&textOfLinks=`description`&rowTpl=`wfListChildOrSibs`&sortBy=`menutitle`&showSubDocCount=`true`&displayStart=`true`&startItemTpl=`wfStartItemWithHeaders``]]
           *
           *    [[showSnippetCall?ss_call=`accessUserProfile`]]
           *
           *
           * Dependencies: MODx Revolution 2.x +
           *
           *
           * Variable lexicon:
           *   Via Snippet call:
           *     $ss_call (string)  actual call of a MODx snippet without brackets
           *     $ss_notcached (bool) [1 | 0]   show snippet call as notcached [[!
           *
           * Snippet internal vars:
           *     $snippet   (object) 
           *     $content  (string) snippet call without backets
           *     $ssPhpPrep  (string) cleans anything the document parser, apache, or php may interpret as code
           ************************************************/
          if (!function_exists(ssPhpPrep)) {
            function ssPhpPrep($value) {
              /**
               *  To purposely alter anything remotely looking like source code
               *   to ModParser, apache, or php
               */
              $value = (strpos($value, "<") !== false) ? htmlentities($value) : $value;
              $value = htmlspecialchars($value);
              $value = str_replace("<", "<", $value);
              $value = str_replace(">", ">", $value);
              $value = str_replace("[", "[", $value);
              $value = str_replace("]", "]", $value);
              $value = str_replace("{", "{", $value);
              $value = str_replace("}", "}", $value);
              return $value;
            }
          }
          if (!empty ($ss_call)) {
            $ss_notcached = (!empty($ss_notcached) && ($ss_notcached === "1")) ? '!' : '';
            /**
             * check for backticks anywhere in the call as MODx will strip the last one off
             * We add it back if we find any available.  We could have also counted the 
             * occurances of ` (backtick) and %2 to make sure we had an even number.
             */
            $pos = strpos($ss_call, '`');
            $ss_call .= ($pos !== false) ? '`' : '';
            return ssPhpPrep('[[' . $ss_notcached . $ss_call . ']]');
          }
          ?>​
          
            • 20308
            • 31 Posts
              • 9207 ☆ A M B ☆
              • 2,475 Posts
              I think Jason built some stuff like that into the core... I saw some of it while looking through the source files somewhere...
                • 4971
                • 964 Posts
                There is an Email Obfuscator snippet for Evo maybe a good time to
                "translate" it to Revo...

                There is also the "Brackify" plugin by pogwatch
                http://www.pogwatch.com/utility/brackify.html
                to print code in Evo... idem...
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner