We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    If it’s a bogus hacking attempt, who cares if the rendering of the POST processing page gets interrupted? I should think we would want it to be. I certainly don’t want their junk in my database, sanitized or not! My only concern was if this format could ever be valid, but it doesn’t appear so; at least not for Jot.

    For my contact page, using eForm with a hidden field, I have my field check function return false if the field is not empty, thus aborting any further processing by eForm. Since I put that in, I haven’t had a single spam contact, but I get plenty of valid contact messages.

    I’ll fiddle with it and see what I can break wink
      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
      • 1122
      • 209 Posts
      Hi, sotwell. Of course, you can break the execution of preserveUrl() function with $modx->sendRedirect(), but we -- you and me -- have in mind different things. By breaking the function you will hardcode into it your interpretation that bogus array necessarily means hacking attempt, while my intention was only to assure that urlencode() function receives formally correct data.
      	function preserveUrl($docid = '', $alias = '', $array_values = array(), $suffix = false) {
      		global $modx;
      		$array_get = $_GET; /* ---- #1 ----  */
      		$urlstring = array();
      		
      		unset($array_get["id"]);
      		unset($array_get["q"]);
      		
      		$array_url = array_merge($array_get, $array_values);
      		foreach ($array_url as $name => $value) {
      			if (!is_null($value)) {
      				#$urlstring[] = urlencode($name) . '=' . urlencode($value);  /* ---- #2 ----  */
      				# #### rewritten by Aleksander Maksymiuk, http://setpro.net.pl/
      				$urlstring[] = urlencode($name) . '=' . urlencode((is_array($value) ? implode('', $value) : $value));
      				# rewritten by Aleksander Maksymiuk ####
      			}
      		}
      		
      		$url = join('&',$urlstring);
      		if ($suffix) {
      			if (empty($url)) { $url = "?"; }
      			 else { $url .= "&"; }
      		}
      
      		return $modx->makeUrl($docid, $alias, $url);
      	}
      

      Author of this function takes in line #1 the data from doubtful source ($_GET[]) and in line #2 is not careful enough about its correctness what leads to parse error. My intention was only to avoid this error. The distinction whether it is hacking attemp or not, IMHO, might be and should be done in more appropriate phase/stage (as I described above).