- Decode patches in the PR body.
- Detect base64 attachments (in the PR). - Grab the filename from UU patches.
This commit is contained in:
parent
86e3e13767
commit
aee39333ee
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/www/; revision=37485
2 changed files with 30 additions and 6 deletions
|
|
@ -24,7 +24,7 @@
|
|||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD: www/en/cgi/GnatsPR.pm,v 1.2 2011/07/21 02:09:02 shaun Exp $
|
||||
# $FreeBSD: www/en/cgi/GnatsPR.pm,v 1.3 2011/07/29 20:37:43 shaun Exp $
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
package GnatsPR;
|
||||
|
|
@ -539,7 +539,12 @@ sub FindPatchStart
|
|||
# UUencoded file. Characteristics:
|
||||
# - Has header and footer.
|
||||
$$text =~ /^begin \d\d\d (.*)/m
|
||||
and return {start => $-[0], type => 'uuencoded'};
|
||||
and return {start => $-[0], type => 'uuencoded', name => $1};
|
||||
|
||||
# Base64 encoded file. Characteristics:
|
||||
# - Has header and footer.
|
||||
$$text =~ /^begin-base64 \d\d\d (.*)/m
|
||||
and return {start => $-[0], type => 'base64', name => $1};
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -583,6 +588,9 @@ sub FindPatchEnd
|
|||
} elsif ($pi->{type} eq 'uuencoded') {
|
||||
$$text =~ /^end$/m
|
||||
and $pi->{size} = $+[0];
|
||||
} elsif ($pi->{type} eq 'base64') {
|
||||
$$text =~ /^====$/m
|
||||
and $pi->{size} = $+[0];
|
||||
}
|
||||
|
||||
if ($pi->{size} == 0) {
|
||||
|
|
|
|||
|
|
@ -24,11 +24,14 @@
|
|||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD$
|
||||
# $FreeBSD: www/en/cgi/GnatsPR/Section/Patch.pm,v 1.1 2011/07/20 22:23:23 shaun Exp $
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
package GnatsPR::Section::Patch;
|
||||
|
||||
use MIME::Base64; # ports/converters/p5-MIME-Base64
|
||||
use Convert::UU qw(uudecode uuencode); # ports/converters/p5-Convert-UU
|
||||
|
||||
use strict;
|
||||
|
||||
require 5.006;
|
||||
|
|
@ -53,6 +56,8 @@ sub new
|
|||
my $self = {
|
||||
text => '',
|
||||
filename => 'patch.txt',
|
||||
binary => 0,
|
||||
encoded => 0,
|
||||
type => 'unknown'
|
||||
};
|
||||
|
||||
|
|
@ -63,6 +68,17 @@ sub new
|
|||
$self->{filename} = $filename if $filename;
|
||||
$self->{type} = $type if $type;
|
||||
|
||||
$self->{filename} =~ '(?:\.gz|\.bz2|\.zip|\.tar)$'
|
||||
and $self->{binary} = 1;
|
||||
|
||||
if ($self->{type} eq 'uuencoded') {
|
||||
$self->{encoded} = 1;
|
||||
$self->{decoded_text} = uudecode($self->{text});
|
||||
} elsif ($self->{type} eq 'base64') {
|
||||
$self->{encoded} = 1;
|
||||
$self->{decoded_text} = decode_base64($self->{text});
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +113,7 @@ sub size
|
|||
{
|
||||
my $self = shift;
|
||||
|
||||
return length($self->{text});
|
||||
return length($self->{encoded} ? $self->{decoded_text} : $self->{text});
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -114,7 +130,7 @@ sub data
|
|||
{
|
||||
my $self = shift;
|
||||
|
||||
return $self->{text};
|
||||
return $self->{encoded} ? $self->{decoded_text} : $self->{text};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -165,7 +181,7 @@ sub isbinary
|
|||
{
|
||||
my $self = shift;
|
||||
|
||||
return 0;
|
||||
return $self->{binary};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue