memcache key double escaped

Maxim Dounin mdounin at mdounin.ru
Thu Feb 26 13:13:06 MSK 2009


Hello!

On Thu, Feb 26, 2009 at 07:33:41AM +0100, Xavier Grangier wrote:

> Hello all,
>
> I have trouble with nginx memcached module with urls containing special 
> char, for instance :
>
> GET /list.xml?fulltext=testé&sort=rating&dir=DESC
>
> will store the following key in memcache :
>
> <25 set brh:262:68:/list.xml?fulltext=test%C3%A9&sort=rating&dir=DESC 0 
> 21600 7006
> >25 STORED
>
> If I query back the same URL I have the following message in nginx debug 
> log :
>
> 2009/02/26 07:16:38 [info] 14614#0: *4684 key: "brh:262:68:/list.xml? 
> fulltext=test%25C3%25A9&sort=rating&dir=DESC" was not found by memcached 
> while reading response header from upstream, client: 10.0.0.177, server: 
> devel.internal.net, request: "GET /list.xml? 
> fulltext=test%C3%A9&sort=rating&dir=DESC HTTP/1.0", upstream:  
> "memcached://10.0.0.177:11211", host: "devel.internal.net"
>
> The request matches the key, eq : fulltext=test%C3%A9
> But the memcache module is double escaping will trying to get the query : 
> fulltext=test%25C3%25A9
>
> I don't know if this is the correct behaviour, of course this can be  
> bypasse using the following code in python for exemple :
>
> urllib.quote("/list.xml?fulltext=test 
> %C3%A9&sort=rating&dir=DESC",safe="&/?=")
>
> $memcached_key is set like this in nginx.conf :
>
> set $memcached_key brh:$prefix:$request_uri;

It's expected as nginx escapes $memcached_key before passing it to 
memcached.  It escapes " ", "%", %00-%1F.

Maxim Dounin





More information about the nginx mailing list