Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

(yakko: URL handler tweaks) Re: Perl/Tk Chatterbox Client

by yakko (Friar)
on Feb 04, 2001 at 04:16 UTC ( #56262=note: print w/ replies, xml ) Need Help??


in reply to Perl/Tk Chatterbox Client

(Update(1): added handling for "+", and Mandrake info)

After a week in the cooker and a couple of revisions, I think I've got a fix for URL passing... at least for me, when I click on a URL, it may not make it to netscape (shell munged it), or netscape won't like it (has commas in it)... so, here's the stuff:

Near the top, right after the comments, you have the usual use stuff. Insert:

use URI::Escape; # escape funky chars out of URLs
I inserted this around line 90, after use PerlMonksChat;

Next, you'll want to go down to the LaunchBrowser sub, where you have at about line 773:

... else { $url = $perlmonksURL . $nod +e; } if ($^O =~ /MSWin32/i) { ...
In between these two lines, I've inserted the magic code to take care of all my weird URL woes[1]:
# escape URL to keep netscape and/or the shell from choking # " " is also unsafe (causes "Doc contains no data" $url=~s/+/%2B/g; # real "+" is preserved $url=~s/\s/+/g; # get rid of whitespace, not just " " $url=uri_escape($url,"\',");
Now, for Unix folks, there's now a duplicate line in the eval block that handled whitespace:
... eval ' my($pid) = fork; $url =~ s/\s/+/g; if ($pid == 0) { ...
Get rid of the $url =~ ... line (line 791 in my original), and you'll be set.

Tested for a week on Unix; some testing by dystrophy on win32. It's taken every URL that folks in the CB and I myself have thrown at it. Let me know if something goes weird.

[1] Alternatively, you may want to toy with the following instead of s///, but I haven't tested this:

$url=uri_escape($url," \',+");
Also, for you Mandrake users, the "netscape" wrapper really mangles URLs with "-" in them. If you find this happening to you, and you haven't got it fixed, I have some diffs for the shell script that have helped me. Just /msg me to let me know you're interested.

--
Me spell chucker work grate. Need grandma chicken.


Comment on (yakko: URL handler tweaks) Re: Perl/Tk Chatterbox Client
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://56262]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-09-16 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (50 votes), past polls