I have seen the answer to this before, but I can't seem to find it now. (Mailing list search is down.) I am generating a URL for a link as follows: http://servername/file?name=<dtml-var name>&id=<dtml-var id> Now if the name is 'Bob' this works fine, but if the name is 'Bob Johnson' the space breaks it. There is a function to encode such a string with the correct hex in place of spaces. What is it? Thanks. -- Guy Davis mailto:davis@arc.ab.ca (403) 210-5334 Alberta Research Council
I *think* it's <dtml-var name url_quote> Guy Davis wrote:
I have seen the answer to this before, but I can't seem to find it now. (Mailing list search is down.) I am generating a URL for a link as follows:
http://servername/file?name=<dtml-var name>&id=<dtml-var id>
Now if the name is 'Bob' this works fine, but if the name is 'Bob Johnson' the space breaks it. There is a function to encode such a string with the correct hex in place of spaces. What is it? Thanks.
-- Guy Davis mailto:davis@arc.ab.ca (403) 210-5334 Alberta Research Council
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough - Digital Creations, Inc. Publishers of Zope - http://www.zope.org
I've always used url_quote_plus for this, which is like url_quote but replaces spaces with '+', which apparently is appropriate for quoting HTML form values. --Brian Hooper On Tue, 08 Feb 2000 19:37:01 -0500 Chris McDonough <chrism@digicool.com> wrote:
I *think* it's <dtml-var name url_quote>
Guy Davis wrote:
I have seen the answer to this before, but I can't seem to find it now. (Mailing list search is down.) I am generating a URL for a link as follows:
http://servername/file?name=<dtml-var name>&id=<dtml-var id>
Now if the name is 'Bob' this works fine, but if the name is 'Bob Johnson' the space breaks it. There is a function to encode such a string with the correct hex in place of spaces. What is it? Thanks.
-- Guy Davis mailto:davis@arc.ab.ca (403) 210-5334 Alberta Research Council
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough - Digital Creations, Inc. Publishers of Zope - http://www.zope.org
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I though the &dtml-var; format automatically url_quoted strings: http://servername/file?name=&dtml-name;&id=&dtml-id; Should work? Phil phil.harris@zope.co.uk | -----Original Message----- | From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Brian | Takashi Hooper | Sent: Wednesday, February 09, 2000 2:16 AM | To: zope@zope.org | Subject: Re: [Zope] Formatting Query Strings | | | I've always used url_quote_plus for this, which is like url_quote but | replaces spaces with '+', which apparently is appropriate for quoting | HTML form values. | | --Brian Hooper | | On Tue, 08 Feb 2000 19:37:01 -0500 | Chris McDonough <chrism@digicool.com> wrote: | | > I *think* it's <dtml-var name url_quote> | > | > Guy Davis wrote: | > > | > > I have seen the answer to this before, but I can't seem to | find it now. | > > (Mailing list search is down.) I am generating a URL for a link as | > > follows: | > > | > > http://servername/file?name=<dtml-var name>&id=<dtml-var id> | > > | > > Now if the name is 'Bob' this works fine, but if the name is 'Bob | > > Johnson' the space breaks it. There is a function to encode such a | > > string with the correct hex in place of spaces. What is it? Thanks. | > > | > > -- | > > Guy Davis mailto:davis@arc.ab.ca | > > (403) 210-5334 Alberta Research Council | > > | > > _______________________________________________ | > > Zope maillist - Zope@zope.org | > > http://lists.zope.org/mailman/listinfo/zope | > > ** No cross posts or HTML encoding! ** | > > (Related lists - | > > http://lists.zope.org/mailman/listinfo/zope-announce | > > http://lists.zope.org/mailman/listinfo/zope-dev ) | > | > -- | > Chris McDonough - Digital Creations, Inc. | > Publishers of Zope - http://www.zope.org | > | > _______________________________________________ | > Zope maillist - Zope@zope.org | > http://lists.zope.org/mailman/listinfo/zope | > ** No cross posts or HTML encoding! ** | > (Related lists - | > http://lists.zope.org/mailman/listinfo/zope-announce | > http://lists.zope.org/mailman/listinfo/zope-dev ) | > | > | | | _______________________________________________ | Zope maillist - Zope@zope.org | http://lists.zope.org/mailman/listinfo/zope | ** No cross posts or HTML encoding! ** | (Related lists - | http://lists.zope.org/mailman/listinfo/zope-announce | http://lists.zope.org/mailman/listinfo/zope-dev ) |
It automatically *html* quotes. Url-quoting is a swamp. If you have a query string, you can't just quote the whole URL, or even the whole query string, since the '?', '&'s, and '='s will get quoted. 'url_quote' works fine on both the path and query, but 'url_quote_plus' only works on the query bits. I bundle all this nastiness up in a method which is called like this: makeURL(base='', path='/where/am/I?', include_last_query=1, swearing='^&*?') to produce: /where/am/I%3f/?bits=from+last+query&swearing=%26%23%5e%26%2a%3f ----- Original Message ----- From: Phil Harris <phil.harris@zope.co.uk>
I though the &dtml-var; format automatically url_quoted strings:
Cheers, Evan @ digicool
Thanks everyone. Both url_quote and url_quote_plus seem to work. http://servername/file?name=&dtml-name;&id=&dtml-id; does not work however as it doesn't properly replace the spaces. -- Guy Davis mailto:davis@arc.ab.ca (403) 210-5334 Alberta Research Council
On Wed, 9 Feb 2000, Guy Davis wrote:
Thanks everyone. Both url_quote and url_quote_plus seem to work.
http://servername/file?name=&dtml-name;&id=&dtml-id; does not work however as it doesn't properly replace the spaces.
You can do this, instead, and it will work (I just tested it): http://servername/file?name=&dtml.url_quote_plus-name; &id=&dtml.url_quote_plus-id; Hope this helps. --Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
participants (6)
-
Brian Takashi Hooper -
Chris McDonough -
Evan Simpson -
Guy Davis -
Jeff K. Hoffman -
Phil Harris