Just wanted to share with the group a possible bug I found in PerForm - I say possible because it might be somewhere else in my code... Basically the issue was this: we have several complicated form pages with validation code for most of the fields, and every so often when a field would (correctly) fail validation the whole page would crash with "output conversion failed due to conv error" -- the page was no longer UTF-8...??!

Eventually I found that the crash was due to an ISO-8859-1 character (a mac-style apostrophe) in a different field. Diacritics normally work fine in the app - on a successful submit, we save it to the database and always encode / decode it properly for AxKit. But when a form field failed to validate, PerForm was trying to spit the raw ISO-8859-1 character into the UTF-8 xml for the field value, which of course failed down the road.

My solution was to modify PerForm.pm, in the textfield and textarea methods:

...
# validate
if ($params->{"__submitting_$fname"}) {
new--> my $conv = Apache::AxKit::CharsetConv->new("ISO-8859-1", "utf-8");
new--> $params->{$name.$index} = $conv->convert(($params->get($name.$index))[-1]);
if (my $sub = $package->can($onval || "validate_${name}")) {
eval {
...


This works for me, converting any input into valid UTF-8 and avoiding crashes if there's a validation error. Does that make sense to be doing that here? Is it a bug in PerForm or am I missing something in my code? Seems like there's no other way to intercept those values and convert them to UTF-8... In either case, thought I'd throw it out there for more experienced PerForm gurus to take a look at.

Thanks,
Nate


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to