"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/perl/confirm-paste" between
rxvt-unicode-9.26.tar.bz2 and rxvt-unicode-9.29.tar.bz2

About: rxvt-unicode is a clone of the terminal emulator rxvt.

confirm-paste  (rxvt-unicode-9.26.tar.bz2):confirm-paste  (rxvt-unicode-9.29.tar.bz2)
#! perl #! perl
=head1 NAME =head1 NAME
confirm-paste - ask for confirmation before pasting multiline text confirm-paste - ask for confirmation before pasting control characters
=head1 DESCRIPTION =head1 DESCRIPTION
Displays a confirmation dialog when a paste containing at least a full Displays a confirmation dialog when a paste containing control characters
line is detected. is detected.
This is mostly meant as a defense-in-depth mechanism to protect against
the common web browser bug of you selecting some text but the browser
pasting a completely different text, which has some attack potential.
It can also be useful to prevent you from accidentally pasting large
amounts of text.
=cut =cut
sub msg { sub msg {
my ($self, $msg) = @_; my ($self, $msg) = @_;
$self->{overlay} = $self->overlay (0, -1, $self->ncol, 2, urxvt::OVERLAY_RSTY LE, 0); $self->{overlay} = $self->overlay (0, -1, $self->ncol, 2, urxvt::OVERLAY_RSTY LE, 0);
$self->{overlay}->set (0, 0, $msg); $self->{overlay}->set (0, 0, $msg);
} }
sub on_tt_paste { sub on_tt_paste {
my ($self, $str) = @_; my ($self, $str) = @_;
my $count = ($str =~ tr/[\x00-\x1f\x80-\x9f]//); my $count = ($str =~ tr/\x00-\x1f\x80-\x9f//)
or return;
return unless $count;
$self->{paste} = \$str; $self->{paste} = \$str;
$self->msg ("Pasting $count control characters, continue? (y/n)"); $self->msg ("Pasting $count control characters, continue? (y/n)");
my $preview = substr $self->locale_decode ($str), 0, $self->ncol; my $preview = substr $self->locale_decode ($str), 0, $self->ncol;
$preview =~ s/\n/\\n/g; $preview =~ s/\n/\\n/g;
$preview =~ s/([\x00-\x1f\x80-\x9f])/sprintf "\\x%02x", ord $1/ge; $preview =~ s/([\x00-\x1f\x80-\x9f])/sprintf "\\x%02x", ord $1/ge;
$self->{overlay}->set (0, 1, $self->special_encode ($preview)); $self->{overlay}->set (0, 1, $self->special_encode ($preview));
$self->enable (key_press => \&key_press); $self->enable (key_press => \&key_press);
1 1
} }
sub leave { sub leave {
my ($self) = @_; my ($self) = @_;
$self->{paste} = undef; $self->{paste} = undef;
 End of changes. 5 change blocks. 
6 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)