Skip to content

Commit

Permalink
Don't clobber $_ in xor_encode
Browse files Browse the repository at this point in the history
  • Loading branch information
amenonsen committed Sep 5, 2012
1 parent 755b885 commit 2d31456
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Mojo/Util.pm
Expand Up @@ -325,9 +325,10 @@ sub xml_escape {
sub xor_encode {
my ($input, $key) = @_;
my $len = length $key;
my $tmp = '';
my $output = '';
$output .= $_ ^ $key while length($_ = substr($input, 0, $len, '')) == $len;
return $output .= $_ ^ substr($key, 0, length, '');
$output .= $tmp ^ $key while length($tmp = substr($input, 0, $len, '')) == $len;
return $output .= $tmp ^ substr($key, 0, length $tmp, '');
}

sub _adapt {
Expand Down

0 comments on commit 2d31456

Please sign in to comment.