--- rxvt-unicode/src/perl/selection 2006/01/17 13:07:16 1.27 +++ rxvt-unicode/src/perl/selection 2006/01/17 16:22:41 1.29 @@ -7,12 +7,10 @@ sub on_start { my ($self) = @_; - $pastebin_cmd = - (urxvt::untaint $self->x_resource ("selection-pastebin-cmd")) + $pastebin_cmd = $self->x_resource ("selection-pastebin-cmd") or "scp -p % ruth:/var/www/www.ta-sa.org/files/txt/"; - $pastebin_url = - (urxvt::untaint $self->x_resource ("selection-pastebin-url")) + $pastebin_url = $self->x_resource ("selection-pastebin-url") or "http://www.ta-sa.org/files/txt/"; (); } @@ -21,27 +19,32 @@ my ($self) = @_; my $txt = $self->selection; - my $h = md5_hex ($txt); + my $filename = md5_hex ($txt) . ".txt"; - my $fn = "/tmp/$h.txt"; + my $tmpfile = "/tmp/$filename"; - my $msg = "uploaded $h.txt"; + my $msg = "uploaded $filename"; - if (open my $o, ">" . $fn) { + if (open my $o, ">" . $tmpfile) { print $o $txt; close $o; } else { - $msg = "couldn't write $fn: $!"; + $msg = "couldn't write $tmpfile: $!"; } my $cmd = $pastebin_cmd; - $cmd =~ s/%/$fn/; - unless (system ($cmd) == 0) { + $cmd =~ s/%/$tmpfile/; + + if (system ($cmd) == 0) { + + my $url = $pastebin_url; + $url =~ s/%/$filename/; + + $self->selection ($url); + } else { $msg = "couldn't upload, '$cmd' failed"; } - $self->selection ($pastebin_url . "$h.txt"); - my $ov = $timers->{ov} = $self->overlay (-1, 0, length ($msg), 1, urxvt::OVERLAY_RSTYLE, 0); $ov->set (0, 0, $msg);