Re: CGI parameters appear to be doubled on 8 bit chars...

2002-10-15 Thread darren chamberlain

* Rob Mueller [EMAIL PROTECTED] [2002-10-13 08:00]:
 Just wondering if anyone has seen this problem before, or has a general
 solution to it. Basically what we see, is that with some submitted forms,
 usually with 8 bit data, the POST parameters passed become 'doubled'. The
 problem is that we have a loop like this to gather out all the parameters
 early on in our handler code.

This isn't a solution, but you could unique the values:

  foreach my $Key ($R-param) {
  my %uniq;
  my @UParam = grep { ++$uniq{$_} == 1 } $R-param($Key);

  $CGIState{$Key} = scalar(@UParam)  1 ? \@UParam : $UParam[0];
  }

(darren)

-- 
You can discover more about a person in an hour of play than in a year
of discussion.
-- Plato



CGI parameters appear to be doubled on 8 bit chars...

2002-10-13 Thread Rob Mueller

Just wondering if anyone has seen this problem before, or has a general
solution to it. Basically what we see, is that with some submitted forms,
usually with 8 bit data, the POST parameters passed become 'doubled'. The
problem is that we have a loop like this to gather out all the parameters
early on in our handler code.

  foreach my $Key ($R-param) {
my ($UKey, UParam) = ($Key, $R-param($Key));

$CGIState{$UKey} = scalar(UParam)  1 ? \@UParam : $UParam[0];
  }

The result is that we end up with an array reference for every parameter,
instead of a scalar value. And we can't just always take the first value,
because multi-select list boxes also return array values, and we don't know
at this stage in the code what type of form element each param comes from.

In general, the values are the same, except where there is 8 bit data, in
which case the 2 versions are different. Here's an example of what we see:

$VAR1 = {
   'LastScreen' = [
 '/MR-@0,324,',
 '/MR-@0,324,'
   ],
   'Subject' = [
 'Blah blah blah',
 'Blah blah blah'
   ],
   'Message' = [
 '#8216;blah blah#8217; blah blah #8216;blah blah#8217; blah.',
 '91blah blah92 blah blah 91blah blah92blah.'
   ]
}

(The 91 etc are highlighted when using 'less', so I presume that probably
means it's hex code 0x91)

So it seems somewhere the 8 bit data is coming as both HTML entity versions,
and the raw 8 bit data version. I'm not sure if this is IE or mod_perl doing
this, though I'm guessing it's IE.

So in general, my questions are:
1. Have people seen this before, and how do you generally deal with it?
2. Actually how do you handle in general 8 bit data? How do you know which
charset it's coming as?
3. Is there any documentation anywhere on why this is happening? Who is
sending the two versions? How to detect it?

Any help or pointers on dealing with these issues would be appreciated.

Thanks

Rob




Re: CGI parameters appear to be doubled on 8 bit chars...

2002-10-13 Thread Steven Lembark


 $VAR1 = {
'LastScreen' = [
  '/MR-@0,324,',
  '/MR-@0,324,'
],
'Subject' = [
  'Blah blah blah',
  'Blah blah blah'
],
'Message' = [
  '#8216;blah blah#8217; blah blah #8216;blah blah#8217; blah.',
  '91blah blah92 blah blah 91blah blah92blah.'
]
 }

If you know the fields that are supposed to have select
lists on them (e.g., select_list{qw(field field field)} = 1)
then you can walk down the list and compare ref $contents with
$select_list{$name}. If both are true then it's a list, else
it's 8 bit junk in two fields; both false gives you a normal
field.




--
Steven Lembark   2930 W. Palmer
Workhorse Computing   Chicago, IL 60647
+1 800 762 1582