url-escaping a string in a shell script.
hi, assuming that i have a string of the form 123%%%blabla*($( available in the shell script, how can i convert that into an escaped version for use with the HTTP protocol? i am not a perl wizard, or else i wouldn't ask. and maybe there is a better way. martin; (greetings from the heart of the sun.) \ echo mailto: !#^.*|tr * mailto:; [EMAIL PROTECTED] -- if you don't understand or are scared by any of the above ask your parents or an adult to help you. pgpUhaSpMjUJE.pgp Description: PGP signature
Re: url-escaping a string in a shell script.
On Sat, Jul 21, 2001 at 01:37:26PM +0200, Martin F. Krafft wrote: hi, assuming that i have a string of the form 123%%%blabla*($( available in the shell script, how can i convert that into an escaped version for use with the HTTP protocol? i am not a perl wizard, or else i wouldn't ask. and maybe there is a better way. perl -MURI::Escape -ne 'chomp; print uri_escape($_), \n' A little scriptlet to do the same: #!/usr/bin/perl -w use URI::Escape; chomp, print uri_escape($_), \n while (); Cheers, Joost
Re: url-escaping a string in a shell script.
also sprach Joost Kooij (on Sat, 21 Jul 2001 01:56:26PM +0200): perl -MURI::Escape -ne 'chomp; print uri_escape($_), \n' A little scriptlet to do the same: #!/usr/bin/perl -w use URI::Escape; chomp, print uri_escape($_), \n while (); almost, except that an input of $1$29492948$6uK7lvoFHD2wWI.P.yF111 is output as $1$29492948$6uK7lvoFHD2wWI.P.yF111 even though the '$' character needs to be escaped for HTTP... why? martin; (greetings from the heart of the sun.) \ echo mailto: !#^.*|tr * mailto:; [EMAIL PROTECTED] -- echo '[dO%O+38%O+PO/d00]Fi22os0CC4BA64E418CE7l0xAP'|dc pgpQ7uhZzDPIh.pgp Description: PGP signature
Re: url-escaping a string in a shell script.
also sprach Joost Kooij (on Sat, 21 Jul 2001 01:56:26PM +0200): perl -MURI::Escape -ne 'chomp; print uri_escape($_), \n' in fact, this doesn't seem to work at all: fishbowl:~ echo '$1$19496519$xnqy/01WTA6pfhLBqZT13.' | \ perl -MURI::Escape -ne 'chomp; print uri_escape($_), \n' $1$19496519$xnqy/01WTA6pfhLBqZT13. what am i doing wrong? martin; (greetings from the heart of the sun.) \ echo mailto: !#^.*|tr * mailto:; [EMAIL PROTECTED] -- 1-800-psych hello, welcome to the psychiatric hotline. if you are co-dependent, please ask someone to press 2. pgpw9hKAqy9e8.pgp Description: PGP signature
Re: url-escaping a string in a shell script.
On Sat, Jul 21, 2001 at 03:11:06PM +0200, Martin F. Krafft wrote: also sprach Joost Kooij (on Sat, 21 Jul 2001 01:56:26PM +0200): perl -MURI::Escape -ne 'chomp; print uri_escape($_), \n' A little scriptlet to do the same: #!/usr/bin/perl -w use URI::Escape; chomp, print uri_escape($_), \n while (); almost, except that an input of $1$29492948$6uK7lvoFHD2wWI.P.yF111 is output as $1$29492948$6uK7lvoFHD2wWI.P.yF111 even though the '$' character needs to be escaped for HTTP... why? Why needs the '$' character be escaped for http? If you insist on escaping everything, use: uri_escape(foo, \0-\377) Of course, this is all explained in the URI::Escape manual page. Cheers, Joost
Re: url-escaping a string in a shell script.
On Sat, Jul 21, 2001 at 03:43:38PM +0200, Martin F. Krafft wrote: in fact, this doesn't seem to work at all: fishbowl:~ echo '$1$19496519$xnqy/01WTA6pfhLBqZT13.' | \ perl -MURI::Escape -ne 'chomp; print uri_escape($_), \n' $1$19496519$xnqy/01WTA6pfhLBqZT13. what am i doing wrong? You read the wrong rfc, the above characters are all allowed in http. Try it again, using spaces, '%', '#' and some control characters. Those will be escaped. Cheers, Joost
Re: url-escaping a string in a shell script.
also sprach Joost Kooij (on Sat, 21 Jul 2001 03:53:58PM +0200): You read the wrong rfc, the above characters are all allowed in http. Try it again, using spaces, '%', '#' and some control characters. Those will be escaped. The restricted set of characters consists of digĀ its, letters, and a few graphic symbols chosen from those common to most of the character encodings and input facilĀ ities available to Internet users: A .. Z, a .. z, 0 .. 9, ;, /, ?, :, @, , =, +, $, ,, # reserved -, _, ., !, ~, *, ', (, ) [...] Some of the uric characters are reserved for use as delimiters or as part of certain URI components. These must be escaped if they are to be treated as ordinary data. Read RFC 2396 for further details. you can see that both '$' and '/' are restricted (reserved characters), and these are escaped by browsers and other HTTP clients during form submissions - which is essentially what i want to fake from the command line. martin; (greetings from the heart of the sun.) \ echo mailto: !#^.*|tr * mailto:; [EMAIL PROTECTED] -- micros~1: for when quality, reliability, and security just aren't that important! pgpqlf0bHaQel.pgp Description: PGP signature
Re: url-escaping a string in a shell script.
On Sat, Jul 21, 2001 at 05:07:23PM +0200, Martin F. Krafft wrote: also sprach Joost Kooij (on Sat, 21 Jul 2001 03:53:58PM +0200): You read the wrong rfc, the above characters are all allowed in http. Try it again, using spaces, '%', '#' and some control characters. Those will be escaped. The restricted set of characters consists of dig? its, letters, and a few graphic symbols chosen from those common to most of the character encodings and input facil? ities available to Internet users: A .. Z, a .. z, 0 .. 9, ;, /, ?, :, @, , =, +, $, ,, # reserved -, _, ., !, ~, *, ', (, ) [...] Some of the uric characters are reserved for use as delimiters or as part of certain URI components. These must be escaped if they are to be treated as ordinary data. Read RFC 2396 for further details. you can see that both '$' and '/' are restricted (reserved characters), and these are escaped by browsers and other HTTP clients during form submissions - which is essentially what i want to fake from the command line. They are not restricted, they are reserved, which the rfc explains as: you can use them, unless the particular uri of which they are a part gives them special meaning, in which case they must be escaped. Read section 2.2 of the rfc. http://www.rfc-editor.org/rfc/rfc2396.txt Of course, if you want to fake the behaviour of webbrowsers, avoid all standards like the plague. Certain browsers will escape all characters when sending a request to the server. Why do you think that .asp sites regularly have spaces in uris, without the designer being aware of that? Cheers, Joost
Re: url-escaping a string in a shell script.
also sprach Joost Kooij (on Sat, 21 Jul 2001 05:27:49PM +0200): Of course, if you want to fake the behaviour of webbrowsers, avoid all standards like the plague. Certain browsers will escape all characters when sending a request to the server. Why do you think that .asp sites regularly have spaces in uris, without the designer being aware of that? well, it's lynx that i am dealing with, so i am assuming a pretty standard-aware browser. anyway, i got it working by specifying all the reserved cpic characters as the second argument to uri_escape. thanks! martin; (greetings from the heart of the sun.) \ echo mailto: !#^.*|tr * mailto:; [EMAIL PROTECTED] -- have you drugged your kids today? pgpobLLEPSB8e.pgp Description: PGP signature