Client_PostParams bug?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Client_PostParams bug?

cJJUNnH41s90Y
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Client_PostParams bug?

Bil Corry
> Client_PostParams bug?

There seems to be an issue with how the client_*params, client_*args and
action_params handle incoming data; they don't all behave in the same manner.  I
give an example here:

http://www.listsearch.com/lassotalk.lasso?id=149362


It's no wonder there are so many encoding questions when the various methods of
getting incoming data produce different results.  This is one area OP really
needs to focus on - all of them should produce the same results.


- Bil

------

Bil Corry
[hidden email]

Enterprise internet application development and security consulting
  http://www.fivegeeks.com/

Tools for Rapid Lasso Development
  http://www.lassoware.com/
 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of
noah williamsson
Sent: Monday, June 06, 2005 8:44 AM
To: [hidden email]
Subject: Client_PostParams bug?

Below is an example of how Client_PostParams mangles utf8 parameters
from multipart forms.

Client_PostParams returns data in something that could've been
ISO-8859-1, but isn't. 'ä' has been decoded to 0x8a, 'ö' to 0x9a and 'å'
to 0x8c. (Correct ISO-8859-1 would've been 0xe4, 0xf6 and 0xe5).

Client_PostArgs work as expected though.


-- From LDML
[Client_PostArgs] returns a string containing all the arguments passed
by a form for the current request. Individual parameters are name/value
pairs with an equals sign, separated by ampersands.

The [Client_PostParams] tag returns the same information pre-parsed into
a pair array.




----------- libcurl example with utf8 data -------------
#include "stdafx.h"
#include "curl/curl.h"

size_t curl_write_func(void *ptr, size_t size, size_t nmemb, void *arg)
{
        // Discard data
        return size * nmemb;
}

int _tmain(int argc, _TCHAR* argv[]) {
        CURL *curl;
        CURLcode curl_res;
        struct curl_httppost *post = NULL, *last = NULL;
        char *str = (char *)malloc(128*1024);
        // "Räksmörgåsar"
        wchar_t *blah = L"Räksmörgåsar";
        int r;

        curl_global_init(CURL_GLOBAL_ALL);
        if((curl = curl_easy_init()) == NULL)
                return -1;

        // Convert wide string data to UTF-8 (Win32 API)
        // (Dont ask me how it knows what charset our input data is
        //  in - just accept the fact that it works ;)
        r = WideCharToMultiByte(CP_UTF8, 0, blah, -1, str, 128*1024,
                                NULL, NULL);
        curl_formadd(&post, &last, CURLFORM_PTRNAME, "utf8",
                                CURLFORM_COPYCONTENTS, str,
                                CURLFORM_CONTENTSLENGTH, r-1,
                                CURLFORM_END);
        curl_easy_setopt(curl, CURLOPT_URL,
                        "http://host/log.lasso");
        curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curl_write_func);
        curl_res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        curl_global_cleanup();
        return 0;
}

-------------------- log.lasso ---------------------------
<?LassoScript
         log: 'logs/a.txt';
                'CLIENT_POSTPARAMS\n' + client_postparams + '\n';
        /log;
         log: 'logs/a.txt';
                'CLIENT_POSTARGS\n' + client_postargs + '\n';
        /log;
?>


------------------- logs/a.txt ----------------------
CLIENT_POSTPARAMS
array: (pair: (utf8)=(Rksmrgsar))
CLIENT_POSTARGS
utf8=R%c3%a4ksm%c3%b6rg%c3%a5sar


------------------- hexdump -C of logs/a.txt --------
   43 4c 49 45 4e 54 5f 50  4f 53 54 50 41 52 41 4d  |CLIENT_POSTPARAM|
   53 0a 61 72 72 61 79 3a  20 28 70 61 69 72 3a 20  |S.array: (pair: |
   28 75 74 66 38 29 3d 28  52 8a 6b 73 6d 9a 72 67  |(utf8)=(R.ksm.rg|
   8c 73 61 72 29 29 0a 43  4c 49 45 4e 54 5f 50 4f  |.sar)).CLIENT_PO|
   53 54 41 52 47 53 0a 75  74 66 38 3d 52 25 63 33  |STARGS.utf8=R%c3|
   25 61 34 6b 73 6d 25 63  33 25 62 36 72 67 25 63  |%a4ksm%c3%b6rg%c|
   33 25 61 35 73 61 72 0a                           |3%a5sar.|


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage



--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage