Return-Path: Delivered-To: apmail-httpd-users-archive@www.apache.org Received: (qmail 70305 invoked from network); 9 Apr 2009 01:48:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Apr 2009 01:48:23 -0000 Received: (qmail 50608 invoked by uid 500); 9 Apr 2009 01:48:20 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 50546 invoked by uid 500); 9 Apr 2009 01:48:19 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 50537 invoked by uid 99); 9 Apr 2009 01:48:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Apr 2009 01:48:19 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of icicimov@gmail.com designates 209.85.198.246 as permitted sender) Received: from [209.85.198.246] (HELO rv-out-0708.google.com) (209.85.198.246) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Apr 2009 01:48:13 +0000 Received: by rv-out-0708.google.com with SMTP id c5so330177rvf.24 for ; Wed, 08 Apr 2009 18:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=UKsv4+Ch8TTo0ZTjteJyvIcc+ofj3B8AQ4n5zYQHD5o=; b=jpk4zeIiZd/hUpjgAvs2jusKjoXvGz8Q5OQOpRo/Q/q+FRiJIqQufgQlLj39NlX4AC uc2aUz8UIj4e90UXs2oICUELYVJonGzsSm7tSmgPujjk66sN3xg4oT5NsLeY+y8viym3 RLEY8O3LOT1j8RQ9TFkgD2hEudvIFjxeUDtks= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=NuYAaDOn8ZpWKl/WzsyRNwW+kfQ43EeTBnCliMrl5Ubq8ojkJ0wiquSCR46/Z7gXJo ezQYY089lvbZtFPRk26J3mcnd2yBilVMQ0LcAzHdVF2FOQ644n8Lo1IJ3Ds4I6h3P3GG gMqHzbqc5n3xbink9BOKo2Ucux+lvOZ9O3mJI= MIME-Version: 1.0 Received: by 10.115.106.18 with SMTP id i18mr1087356wam.213.1239241673503; Wed, 08 Apr 2009 18:47:53 -0700 (PDT) In-Reply-To: References: <49D63626.5060802@ice-sa.com> Date: Thu, 9 Apr 2009 11:47:53 +1000 Message-ID: From: Igor Cicimov To: users@httpd.apache.org Content-Type: multipart/alternative; boundary=00163646c222bd7f8c0467156f67 X-Virus-Checked: Checked by ClamAV on apache.org Subject: Re: [users@httpd] Query string encoding --00163646c222bd7f8c0467156f67 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Just an idea ... have you tried putting the hexadecimal representation of the "+" symbol so apache translates it into "+" when encoding? On Wed, Apr 8, 2009 at 11:19 PM, Clodoaldo Pinto Neto < clodoaldo.pinto@gmail.com> wrote: > 2009/4/7 Clodoaldo Pinto Neto : > > 2009/4/3 Andr=E9 Warnier : > >> Clodoaldo Pinto Neto wrote: > >>> > >>> I want to rewrite a url to a query string like this: > >>> > >>> from http://example.com/x+ to http://example.com/var=3Dx%2B > >>> or > >>> from http://example.com/x%2B to http://example.com/var=3Dx%2B > >>> > >>> Using: > >>> RewriteRule ^(/([\w-()+]+))?/$ /?var=3D$2 [QSA] > >>> > >>> The problem i have is that the query string is passed to the > >>> application unencoded so the "+" is understood by the application as > >>> space. How to reencode the query string before it is passed to the > >>> application? > >>> > >> Hi. > >> I don't really know why precisely, but I have a bad feeling about the > above, > >> in the sense that an initial URL like you show two examples above may > lead > >> to trouble at some point. > >> > >> But assuming you insist.. > >> > >> You may want to lookup this page : > >> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html > >> in the following sections : > >> Internal Function (escape) > >> or > >> External Rewriting Program > > > > I could not make the internal escape function work for me. So I used > > an external rewriting program. If someone is interested this is it: > > > > #!/usr/bin/env python > > > > from sys import stdin as si > > from sys import stdout as so > > from urllib import quote > > > > linha =3D si.readline() > > si.flush > > while linha: > > so.write(quote(linha, '/\n')) > > so.flush() > > linha =3D si.readline() > > si.flush() > > Flushing input makes no sense to me so I deleted them and it still > works. If I'm wrong please comment. > > Regards, Clodoaldo > > > > > Then in httpd.conf: > > > > RewriteMap escape_url prg:/home/carroarodo/escape_url.py > > RewriteRule ^(.*)$ ${escape_url:$1} > > > > Regards, Clodoaldo > > > >> > >> I have never used them, and I am not sure they allow to create the > >> query-string part of the rewritten request. > >> But it's worth trying out. > >> Otherwise, mod_perl would be your friend. > >> > >> --------------------------------------------------------------------- > >> The official User-To-User support forum of the Apache HTTP Server > Project. > >> See for more info. > >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org > >> " from the digest: users-digest-unsubscribe@httpd.apache.org > >> For additional commands, e-mail: users-help@httpd.apache.org > >> > >> > > > > --------------------------------------------------------------------- > The official User-To-User support forum of the Apache HTTP Server Project= . > See for more info. > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org > " from the digest: users-digest-unsubscribe@httpd.apache.org > For additional commands, e-mail: users-help@httpd.apache.org > > --00163646c222bd7f8c0467156f67 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Just an idea ... have you tried putting the hexadecimal representation of t= he "+" symbol so apache translates it into "+" when enc= oding?

On Wed, Apr 8, 2009 at 11:19 PM, C= lodoaldo Pinto Neto <clodoaldo.pinto@gmail.com> wrote:
2009/4/7 Clodoald= o Pinto Neto <clodoaldo.pin= to@gmail.com>:
> 2009/4/3 Andr=E9 Warnier <aw@ice-sa.com>:
>> Clodoaldo Pinto Neto wrote:
>>>
>>> I want to rewrite a url to a query string like this:
>>>
>>> from http:= //example.com/x+ to http://example.com/var=3Dx%2B
>>> or
>>> from htt= p://example.com/x%2B to http://example.com/var=3Dx%2B
>>>
>>> Using:
>>> RewriteRule ^(/([\w-()+]+))?/$ /?var=3D$2 [QSA]
>>>
>>> The problem i have is that the query string is passed to the >>> application unencoded so the "+" is understood by th= e application as
>>> space. How to reencode the query string before it is passed to= the
>>> application?
>>>
>> Hi.
>> I don't really know why precisely, but I have a bad feeling ab= out the above,
>> in the sense that an initial URL like you show two examples above = may lead
>> to trouble at some point.
>>
>> But assuming you insist..
>>
>> You may want to lookup this page :
>> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html=
>> in the following sections :
>> Internal Function (escape)
>> or
>> External Rewriting Program
>
> I could not make the internal escape function work for me. So I used > an external rewriting program. If someone is interested this is it: >
> #!/usr/bin/env python
>
> from sys import stdin as si
> from sys import stdout as so
> from urllib import quote
>
> linha =3D si.readline()
> si.flush
> while linha:
> =A0 so.write(quote(linha, '/\n'))
> =A0 so.flush()
> =A0 linha =3D si.readline()
> =A0 si.flush()

Flushing input makes no sense to me so I deleted them and it st= ill
works. If I'm wrong please comment.

Regards, Clodoaldo

>
> Then in httpd.conf:
>
> RewriteMap escape_url prg:/home/carroarodo/escape_url.py
> RewriteRule ^(.*)$ ${escape_url:$1}
>
> Regards, Clodoaldo
>
>>
>> I have never used them, and I am not sure they allow to create the=
>> query-string part of the rewritten request.
>> But it's worth trying out.
>> Otherwise, mod_perl would be your friend.
>>
>> ------------------------------------------------------------------= ---
>> The official User-To-User support forum of the Apache HTTP Server = Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info= .
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> =A0" =A0 from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.<= br> See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
=A0 " =A0 from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


--00163646c222bd7f8c0467156f67--