Mantis - Quercus
Viewing Issue Advanced Details
2272 block always 12-21-07 18:43 01-24-08 12:34
rvt  
nam  
normal  
closed 3.1.3  
fixed  
none    
none 3.1.5  
0002272: X/Y location of pressed area on form type image is incorrectly passed to the _POST variable
Wen using this input form type :
<input type="image" src="image.gif" name="sub" />

We should get in the $_POST variable the following coordinates:
$x = $_POST['sub_x'];
$y = $_POST['sub_y'];

However in quercus they are retreived as (according to W3C correctly):
$x = $_POST['sub.x'];
$y = $_POST['sub.y'];

So basically Quercus does it correctly, and PHP does internally convert the . to an _.

The proper solution would be to convert the . to an _ on incoming form variables.

Ries

thanks,
Ries
According to : W3C http://www.w3.org/TR/html4/interact/forms.html [^]
According to PHP: http://www.php.net/variables.external [^] (section IMAGE SUBMIT variable names)

Notes
(0002596)
rvt   
12-21-07 19:08   
To explain a bit better I made a example how to test this:

<?php
print '<form action="formtest.php" method="post" enctype="multipart/form-data" name="editform">';
print '<input type="image" src="http://www.rvantwisk.nl/typo3temp/pics/4341200a6d.jpg" [^] name="location" />';
print '</form>';
var_dump($_POST);
 ?>

mod_php:
array(2) { ["location_x"]=> string(2) "37" ["location_y"]=> string(2) "12" }

Quercus:
array(2) { ["location.x"]=> string(2) "37" ["location.y"]=> string(2) "12" }
(0002661)
rvt   
01-18-08 20:23   
I hate to admit, but I made a mistake, this is a new patch:

Index: modules/quercus/src/com/caucho/quercus/env/Post.java
===================================================================
--- modules/quercus/src/com/caucho/quercus/env/Post.java (revision 3660)
+++ modules/quercus/src/com/caucho/quercus/env/Post.java (working copy)
@@ -290,7 +290,7 @@
 
       if (p > 0) {
        key = key.substring(0, p);
-
+ key = key.replace('.', '_');
        keyValue = env.createString(key);
        existingValue = array.get(keyValue);
 
@@ -361,6 +361,11 @@
         put(array, env.createString(index), formValue, addSlashesToValues);
     }
     else {
+ if (p>0) {
+ key = key.substring(0, p).replace('.','_') + "_" + key.substring(p+1, key.length());
+ } else {
+ key = key.replace('.', '_');
+ }
       put(array, env.createString(key), formValue, addSlashesToValues);
     }
   }


The reason behind this is that php will replace the . for a _ always before a [ is found, and when only a open bracket is found but not a closing bracket then teh open bracket will be replaced for an _.

print '<input type="text" name="T[f.p][t_b.c]" value="root">';
print '<input type="text" name="T[s.x][a.b_c]" value="12">';
print '<input type="text" name="ries2.y" value="12">';
print '<input type="text" name="ries2.q" value="12">';
print '<input type="text" name="a.b.c[[[[d" value="12">';
print '<input type="text" name="a.b.c]]]]d" value="12">';
print '<input type="text" name="q.b.c.[[[d" value="12">';
print '<input type="text" name="my.var[array.var" value="12">';
print '<input type="text" name="my.var.test[array.var.test" value="12">';

array(10) {
  ["T"]=>
  array(2) {
    ["f.p"]=>
    array(1) {
      ["t_b.c"]=>
      string(4) "root"
    }
    ["s.x"]=>
    array(1) {
      ["a.b_c"]=>
      string(2) "12"
    }
  }
  ["ries2_y"]=>
  string(2) "12"
  ["ries2_q"]=>
  string(2) "12"
  ["a_b_c_[[[d"]=>
  string(2) "12"
  ["a_b_c]]]]d"]=>
  string(2) "12"
  ["q_b_c__[[d"]=>
  string(2) "12"
  ["my_var_array.var"]=>
  string(2) "12"
  ["my_var_test_array.var.test"]=>
  string(2) "12"
}

(0002680)
nam   
01-24-08 12:34   
php/081h
php/081i