From e3cb17e173ccbba0eb27b22c46f69f635bee2dc7 Mon Sep 17 00:00:00 2001 From: "Difrex(Denis Zheleztsov)" Date: Wed, 6 Aug 2014 12:16:16 +0400 Subject: [PATCH] Long messages fix. --- II/Enc.pm | 9 +++------ II/Get.pm | 19 ++++--------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/II/Enc.pm b/II/Enc.pm index 389d48b..feb7acc 100644 --- a/II/Enc.pm +++ b/II/Enc.pm @@ -21,11 +21,7 @@ sub new { sub decrypt { my ( $self, $base64 ) = @_; - # Decrypt message - my $dec = decode_base64($base64); - # my $dec = `echo "$base64" | base64 -d`; - - return $dec; + return decode_base64($base64); } sub encode { @@ -42,7 +38,8 @@ sub encode { $message .= '@repto:' . $data->{hash} . "\n" if defined( $data->{hash} ); $message .= $data->{post}; - my $encoded = `echo "$message" | base64`; + # my $encoded = `echo "$message" | base64`; + my $encoded = encode_base64($message); $encoded =~ s/\//_/g; $encoded =~ s/\+/-/g; diff --git a/II/Get.pm b/II/Get.pm index 2769e7f..21181bd 100644 --- a/II/Get.pm +++ b/II/Get.pm @@ -72,33 +72,22 @@ sub get_echo { } $db->commit(); - # Get messages - my @msg_con; + # Get messages and populate hash my $count = 0; while ( $count < @new ) { my $new_messages_url = "$host$msg_url" . $new[$count]->{hash}; my $req_msg = HTTP::Request->new( GET => $new_messages_url ); my $res_msg = $ua->request($req_msg); + if ( $res_msg->is_success() ) { - push( @msg_con, $res_msg->content() ); + my ( $hash, $m ) = split(':', $res_msg->content()); + push( @messages_hash, { hash => $hash, base64 => $m } ); } else { print $res_msg->status_line, "\n"; } $count++; } - - # Populate hash - while (<@msg_con>) { - my @message = split /:/, $_; - if ( defined( $message[1] ) ) { - my $h = { - hash => $message[0], - base64 => $message[1], - }; - push( @messages_hash, $h ); - } - } } my $new_messages