libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Escaped characters in URL


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Escaped characters in URL
Date: Wed, 23 Sep 2015 15:44:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0

On 09/23/2015 03:41 PM, address@hidden wrote:
>  
> 
> Hi Christian,
> 
> You're right, I am walking through the URL to extract the keys and values.

Great, that explains it then.

> I wrote this 5 years ago and I must have misunderstood the mechanism at
> the time. I still don't quite understand why the strlen method fails for
> escaped characters.

Because MHD tries to avoid moving data in memory, so when it unescapes
the URL, it only moves the rest of the current key or value, but keeps
the starting points of subsequent key-value pairs unchanged. Thus,
unescaping creates an unpredictable gap after the end of the string.

> I guess I need to rewrite it and call MHD_get_connection_values with a
> callback to handle all possible name/value pairs. This sounds like a
> better option than multiple calls to MHD_lookup_connection_value, as
> there are lots of key/value pairs which are optionally present in the
> API URL.

Sure, that's why we have two functions, which one you use totally
depends on your application.

Happy hacking!

Christian

Attachment: 0xE29FC3CC.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]