Recent Changes - Search:

PmWiki

pmwiki.org

01032

Summary: function InputDefault in forms.php does not process arrays as input values
Created: 2008-07-04 12:33
Status: Open
Category: Bug
From: HansB
Assigned:
Priority: 5
Version: 2.2 beta65
OS:

Description: sometimes it is necessary to use form input controls which are named as elements in an array, like target[0], target[1], target[2], or in select boxes. The InputDefault function does not process these, and throws php warnings.

I suggest a code change inside the InputDefault function to this snippet:

if (@$args['request']) {
  $req = array_merge($_GET, $_POST);
    foreach($req as $k => $v) {
      if (is_array($v)) {
        foreach($v as $kk => $vv)
          if (!isset($InputValues[$k][$kk])) 
            $InputValues[$k][$kk] = htmlspecialchars(stripmagic($vv), ENT_NOQUOTES); 
      }
      else if (!isset($InputValues[$k]))
        $InputValues[$k] = htmlspecialchars(stripmagic($v), ENT_NOQUOTES);
   }
}

Similarly the RequestArgs function in forms.php does not process arrays. Would be nice to havethat fixed as well. I suggest a code change inside the RequestArgs function to this snippet:

if (is_null($req)) $req = array_merge($_GET, $_POST);
foreach ($req as $k=>$v) {
  if(is_array($v))
    foreach($v as $kk=>$vv)
      $req[$k][$kk] = str_replace("\r",'',stripmagic($vv));
  else $req[$k] = str_replace("\r",'',stripmagic($v));
}
return $req;
Edit - History - Print - Recent Changes - Search
Page last modified on July 04, 2008, at 12:41 PM