Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

to-url

 [1/7] from: tim::johnsons-web::com at: 5-Jan-2003 17:01


Hello : I have some questions about to-url here: supose I want to create a query-string in a url that has letters like "?=&" inside of the values.
>> to-url "Father & sons"
== Father & sons ;yikes, shouldn't we get Father %26 son ('&' is hex 26, right?) ; decoding this will give incorrect results, I think... Comments and suggestions welcome -- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [2/7] from: carl:cybercraft at: 6-Jan-2003 15:56


On 06-Jan-03, Tim Johnson wrote:
> Hello : > I have some questions about to-url here:
<<quoted lines omitted: 6>>
> ; decoding this will give incorrect results, I think... > Comments and suggestions welcome
I just searched google for "a & b" to see how it'd make its URL, and this is what it returned... http://www.google.co.nz/search?q=a+%26+b&ie=ISO-8859-1&hl=en&btnG=Google+Search My guess would be that you'd convert to %26 if it's part of some text, but leave as-is if it's for breaking up the query. (A guess mind - others here will know the rules I'm sure.) -- Carl Read

 [3/7] from: tim:johnsons-web at: 5-Jan-2003 18:36


* Carl Read <[carl--cybercraft--co--nz]> [030105 18:19]:
> On 06-Jan-03, Tim Johnson wrote: > > Hello :
<<quoted lines omitted: 13>>
> but leave as-is if it's for breaking up the query. (A guess mind - > others here will know the rules I'm sure.)
Hi Carl: Great minds run in the same gutter! It would seem that rebol's native funcs aren't taking this into consideration. ; I just churned this out. Hopefully someone has a better ; solution, if not, pointers are welcome to docs on ; other chars to be escaped. url-str: def[str[string!]][ encode: [#"%" "%25" #"&" "%26" #"=" "%3D" #" " " "] new-str: make string! (length? str) * 2 ;oh, just an estimate repeat char str[ either found: select encode char [append new-str found] [append new-str char] ]new-str ] -tim-
> -- > Carl Read > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [4/7] from: al:bri:xtra at: 6-Jan-2003 16:59


Carl's got it right here. Andrew Martin ICQ: 26227169 http://valley.150m.com/ -><- ----- Original Message ----- From: "Carl Read" <[carl--cybercraft--co--nz]> To: <[rebol-list--rebol--com]> Sent: Monday, January 06, 2003 3:56 PM Subject: [REBOL] Re: to-url
> On 06-Jan-03, Tim Johnson wrote: > > Hello :
<<quoted lines omitted: 9>>
> I just searched google for "a & b" to see how it'd make its URL, and > this is what it returned...
http://www.google.co.nz/search?q=a+%26+b&ie=ISO-8859-1&hl=en&btnG=Google+Sea rch

 [5/7] from: tim:johnsons-web at: 5-Jan-2003 19:39


Okay Folks: Some of you are having your coffee and feeling bright-eyed and bushy-tailed. Me, I'm in the frozen North and at the end of a very short day but sleepy. Here's an attempt that would escape any none-url-acceptable char in the 'encode string. ; NOTE 'def is Andrew's 'fun/deep function esc-char: def[ch[char!]][ join "%" enbase/base to-string ch 16 ] url-str: def[str[string!]][ encode: "%&= " ; add any more from http rfc new-str: make string! (length? str) * 3 ; let's be generous repeat char str[ either found: find encode char [append new-str esc-char char] [append new-str char] ]new-str ] You think? Hack me up, it just gives me good code back! (But this really could be a native huh?) -tim- * Andrew Martin <[Al--Bri--xtra--co--nz]> [030105 19:19]:
> Carl's got it right here. > Andrew Martin
<<quoted lines omitted: 41>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com http://www.johnsons-web.com

 [6/7] from: tomc:darkwing:uoregon at: 6-Jan-2003 0:45


Hi Tim the url-encode in the library handels it ... well it use to be in the lib under web ... now I am only seeing it being used in other peoples scripts, maybe it is being cleaned up by the library people
>> url-encode "Father & Son"
== "Father+%26+Son" there is a copy at http://www.cs.uoregon.edu/~tomc/url-encode.r On Sun, 5 Jan 2003, Tim Johnson wrote:

 [7/7] from: greggirwin:mindspring at: 6-Jan-2003 7:59


Hi Tom, TC> the url-encode in the library handels it ... well it use to be in the TC> lib under web ... now I am only seeing it being used in other peoples TC> scripts, maybe it is being cleaned up by the library people Our first pass on the library is more of a clean-up sweep, but I found it in HTTP-post (as the earliest reference) and will add it to my list of handy things people might want included. Thanks! -- Gregg (Library Team)

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted