[jifty-devel] canonicalize_ ajax call not doing the right thing

Shawn M Moore sartak at bestpractical.com
Mon Jan 14 19:20:43 EST 2008

On Wed, Jan 09, 2008 at 12:27:47PM +0100, Peter Mottram wrote:
> Jesse Vincent wrote:
> >Peter Mottram wrote:
> >>I'm seeing some weirdness when using canonicalize_ inside my model as
> >>there is a difference between how the ajax call handles things (badly)
> >>and how the final POST request handles things (correctly).
> >>
> >>Here's an extract of the relevant parts of my model:
> >
> >>So the ajax validator sees an empty value! If I enter somthing nice and
> >>simple like '45th e4' then the result via ajax is correct as it returns
> >>'45THE4'.
> >>
> >>Could someone please point me in the right direction as to where to
> >>start poking around in the Jifty code?
> >
> >I'd definitely start with the firebug XmlHttpRequest logging to see
> >what's being posted to the server. Is the problem on the js side or the
> >perl side?
> Checking with firebug shows a perl problem since the failing canonicalize 
> does not get an 'update' returned to js in the xml.
> >From there, it should be pretty easy to add a model to the
> >jifty TestApp and a small test file which reproduces the problem using
> >Test::WWW:Mechanize. Once you've done that, send a patch to jifty-devel,
> >and make it all our problem ;)
> I have attached a patch which includes a test case which passes and also 
> one that fails. I added the tests to 06-validation.t rather than creating 
> a new test file - hope that is OK.
> Cheers
> PeteM

Hi Pete,

I looked into it, and the problem is specifically the ';' character. CGI
is intepreting that as a delimiter (as per RFC 3986). That's why
the canonicalize_column_1 method is being called with the empty string.
Here's what the action's arguments looks like to Jifty:

$HASH1 = {
           f              => '',
                          => 'TestApp::Action::CreateCanonTest',
                          => '',
           "J:VALIDATE"   => 1

This explains the test failures: the parameter needs to be '%3Bf'
instead of ';f'. Changing that causes the two tests to pass.

However, it doesn't explain the behavior you were seeing. jifty.js does
percent-encode the parameter correctly. Are you running an old version?
Does it fail on standalone?


More information about the jifty-devel mailing list