[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

API URL encoding



Hello!

I have an application that communicates with my LSMB server via the POST method (with a content type of "x-www-form-urlencoded") to the general ledger moduel (gl.pl).  I'm having difficulty with some of my URL encoding and how LSMB is decoding my POST data.  For example...  The following POST data works and my transaction is correctly posted.

login=TradingRecord&password=joseph1n3&path=bin/mozilla&action="">

However, this POST data produces the error shown below eventhough it should be equivalent, if not even more proper than the above URL.

login=TradingRecord&password=joseph1n3&path=bin%2Fmozilla&action="">

DBD::Pg::st execute failed: ERROR:  null value in column "chart_id" violates not-null constraint
Error!
INSERT INTO acc_trans 
           (trans_id, chart_id, amount, 
           transdate, source, project_id, 
           fx_transaction, memo, cleared)
   VALUES  (?, (SELECT id
                  FROM chart
                 WHERE accno = ?),
          ?, ?, ?, ?, ?, ?, ?)
ERROR:  null value in column "chart_id" violates not-null constraint

This tells me that the LedgerSMB/Form.pm module isn't properly decoding the URL encoding.  I found the following lines in LedgerSMB/Form.pm:


$str =~ tr/+/ /;
$str =~ s/%([0-9a-fA-Z]{2})/pack("c",hex($1))/eg;

First, I think the regexp should be [0-9a-fA-F] and not [0-9a-fA-Z].  Anyway, this would appear to properly decode the URL.  But, for some reason it doesn't.  If I replace the "%5F"s in the problem URL and replace all of them with "_".  Then the above URL works.  

So, it would appear that somewhere in the LSMB code "%5F" isn't being properly decoded.

Can someone please help me?

Thanks!
Mark