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

API URL encoding


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.


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


DBD::Pg::st execute failed: ERROR:  null value in column "chart_id" violates not-null constraint
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?