← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 03:09:29 2017
Reported on Mon Nov 6 13:20:48 2017

Filename/usr/local/lib/perl5/site_perl/mach/5.24/Razor2/Preproc/deBase64.pm
StatementsExecuted 1 statements in 6µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sRazor2::Preproc::deBase64::::doitRazor2::Preproc::deBase64::doit
0000s0sRazor2::Preproc::deBase64::::extract_base64Razor2::Preproc::deBase64::extract_base64
0000s0sRazor2::Preproc::deBase64::::isitRazor2::Preproc::deBase64::isit
0000s0sRazor2::Preproc::deBase64::::newRazor2::Preproc::deBase64::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Razor2::Preproc::deBase64;
2
3
4sub new {
5 return bless {}, shift;
6}
7
8
9sub isit {
10 my ($self, $text) = @_;
11 return $$text =~ /^Content-Transfer-Encoding: base64/sim;
12}
13
14
15sub doit {
16 my ($self, $text) = @_;
17
18 my ($hdr, $body) = split /\n\r*\n/, $$text, 2;
19
20 $body = $self->extract_base64($text);
21
22 $body =~ tr|A-Za-z0-9+=/||cd; # remove non-base64 chars
23 $body =~ s/=+$//; # remove padding
24 $body =~ tr|A-Za-z0-9+/| -_|; # convert to uuencoded format
25
26 my $decoded = '';
27 while ($body =~ /(.{1,60})/gs) {
28 my $len = chr(32 + length($1)*3/4); # compute length byte
29 $decoded .= unpack("u", $len . $1 ); # uudecode
30 }
31
32 $$text = "$hdr\n\n$decoded";
33}
34
35
36sub extract_base64 {
37 my ($self, $text) = @_;
38
39 if ($$text =~ /Content-Transfer-Encoding: base64(.*)$/si) {
40 my $rhs = $1;
41 $rhs =~ /\r?\n\r?\n([^=]*)/s; # match to end of data or '='
42 return $1 . "==";
43 }
44 return undef;
45}
46
47
4816µs1;
49