Re: hex to binary conversion for xml post

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
you got it :)

Thanks,
Alexander Malysh
 
Am 09.03.2011 um 04:52 schrieb Nikos Balkanas:

>> but what about if someone wishes to xmp-post '0102030405' as text instead of '12345'?
> 
> Scratch that. You can simply post '00010002000300040005'.
> 
> BR,
> Nikos
> ----- Original Message ----- From: "Nikos Balkanas" <[email protected]>
> To: "Alexander Malysh" <[email protected]>
> Cc: "Emanuele Carbone" <[email protected]>; <[email protected]>
> Sent: Wednesday, March 09, 2011 5:34 AM
> Subject: Re: hex to binary conversion for xml post
> 
> 
>> Hi,
>> 
>> octstr_hex_to_binary uses gw_isxdigit to test for hex chars, which in turn uses the Clib isxdigit to test for [0-9][a-f]&[A-F]. This is valid for regular Hex characters, however body in HTTP post should be url-encoded:
>> 
>> '12345' => '%31%32%33%34%35'
>> 
>> gw_isxdigit aside from isxdigit should also check for a single '%' every 2 chars.  I understand your argument about breaking existing installations, but what about if someone wishes to xmp-post '0102030405' as text instead of '12345'?
>> 
>> BR,
>> Nikos
>> ----- Original Message ----- From: "Alexander Malysh" <[email protected]>
>> To: "Nikos Balkanas" <[email protected]>
>> Cc: "Emanuele Carbone" <[email protected]>; <[email protected]>
>> Sent: Wednesday, March 09, 2011 12:22 AM
>> Subject: Re: hex to binary conversion for xml post
>> 
>> 
>> Hi,
>> 
>> why do you think, it should be a bug?
>> You see old code, new code:
>> 
>>   /* text */
>>   XPATH_SEARCH_OCTSTR("/message/submit/ud", text, 0);
>>   if (text != NULL && octstr_hex_to_binary(text) == -1)
>>       octstr_url_decode(text);
>> 
>> And this is simple, try hex encoding 12345 (0102030405) and set it as text.
>> 
>> Thanks,
>> Alexander Malysh
>> 
>> P.S. Changing this behavior will break existing setups and this for no good reason.
>> 
>> Am 02.03.2011 um 16:48 schrieb Nikos Balkanas:
>> 
>>> Hi,
>>> 
>>> This is a bug. Code scans your text for any non-hex chars. Since all chars, 12345 are valid hex chars, it assumes that text is in hex and tries to decode it. It should be fixed to require the '%' for url-encoded hex chars.
>>> 
>>> BR,
>>> Nikos
>>> ----- Original Message ----- From: Emanuele Carbone
>>> To: [email protected]
>>> Sent: Wednesday, March 02, 2011 4:08 PM
>>> Subject: hex to binary conversion for xml post
>>> 
>>> 
>>> Hi guys,
>>> 
>>> 
>>> i tried to send a simple sms with this text "12345"  (without quotes). The request was done in XML POST  and i have received a strange sequence of character. But  if the same request is done in GET i receive the correct message. Smsbox when received a xml request extract the text so:
>>> 
>>> 
>>> /* text */
>>>  text = NULL;
>>>  get_tag(*body, octstr_imm("ud"), &tmp, 0, 0);
>>>  if(tmp) {
>>> O_DESTROY(text);
>>> text = octstr_duplicate(tmp);
>>> if(octstr_hex_to_binary(text) == -1)
>>> octstr_url_decode(text);
>>> O_DESTROY(tmp);
>>>  }
>>> 
>>> 
>>> with the text 12345: (but it is true for the all hex symbols)
>>> 
>>> 
>>> octstr_check_range(ostr, 0, ostr->len, gw_isxdigit) is valid
>>> 
>>> 
>>> and the function convert ascii data to binary values. This action compromise my text.
>>> 
>>> 
>>> I don't understand why for xml request smsbox do this check.
>>> 
>>> 
>>> 
>>> 
>>> Please, can anyone explain the reason?!
>>> 
>>> 
>>> thanks in advance
>>> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.