diff options
Diffstat (limited to 'lib/Devel/Mwrap/Rproxy.pm')
-rw-r--r-- | lib/Devel/Mwrap/Rproxy.pm | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/Devel/Mwrap/Rproxy.pm b/lib/Devel/Mwrap/Rproxy.pm index d5a9d9d..de65685 100644 --- a/lib/Devel/Mwrap/Rproxy.pm +++ b/lib/Devel/Mwrap/Rproxy.pm @@ -11,9 +11,8 @@ package Devel::Mwrap::Rproxy; use v5.12; # strict use Fcntl qw(SEEK_SET); use IO::Socket::UNIX; -use Plack::Util; -sub new { bless { socket_dir => $_[1]}, $_[0] } +sub new { require Plack::Util; bless { socket_dir => $_[1]}, $_[0] } sub r { [ $_[0], [ @@ -104,13 +103,26 @@ sub a2l { $a2l ? do { chomp(my $line = $a2l->lookup($addr)); $line =~ s/\Q?? at ??:0\E//; # FreeBSD - $line = Plack::Util::encode_html($line); $line =~ /\?\?/ ? "$line $exe($addr)" : ($line =~ /\S/ ? $line : "$exe($addr)"); } : "$exe($addr)" } } +sub decode_csv { + my ($in, $out) = @_; + while (<$in>) { + s/\\n/\0\0/g; + s!(["\0]) + ([^\("\0]+) # exe + \(([^\)"\0]+)\) # addr + (["\0])! + $1.a2l($2,$3).$4!gex; + s/\0\0/\\n/g; + $out->write($_); + } +} + sub call { # PSGI entry point my ($self, $env) = @_; my $uri = $env->{REQUEST_URI}; @@ -152,23 +164,16 @@ sub call { # PSGI entry point local %addr2line; # extract executable|library(address) if ($csv) { - while (<$c>) { - s/\\n/\0\0/g; - s!(["\0]) - ([^\("\0]+) # exe - \(([^\)"\0]+)\) # addr - (["\0])! - $1.a2l($2,$3).$4!gex; - s/\0\0/\\n/g; - $http_out->write($_); - } + decode_csv($c, $http_out); } else { while (<$c>) { s!> ([^\(<]+) # exe \(([^\)<]+)\) # addr <! - '>'.a2l($1,$2).'<'!gex; + '>'.Plack::Util::encode_html( + a2l($1,$2)). + '<'!gex; $http_out->write($_); } } |