Mercurial > hgrepos > hgweb.cgi > s4
annotate mpsplit.pl @ 737:441768a11b84
Joingrp use var-name adduser instead of user
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 04 Jun 2020 06:56:20 +0900 |
parents | 07863b13e3f9 |
children | 1ba114ebcf2c |
rev | line source |
---|---|
11 | 1 #!/usr/bin/env perl |
2 $sep = "--" . $ARGV[0]; | |
3 $dir = ($ARGV[1] || "tmp"); | |
12 | 4 if ($dir =~ /^([^<>\;\&]*)$/) { |
5 $dir = $1; | |
6 } | |
11 | 7 |
8 #print "sep=".$sep, "dir=$dir\n"; | |
9 #binmode STDIN; | |
10 $/ = undef; | |
11 $stream = (<STDIN>); | |
12 $n=0; | |
13 @slices = split($sep, $stream); | |
14 shift(@slices); | |
15 pop(@slices); | |
16 foreach $item (@slices) { | |
17 $item =~ s/^\n//; | |
18 ($header = $item) =~ s/\r\n\r\n.*//s; | |
19 ($body = $item) =~ s/.*?\r\n\r\n//s; | |
20 $body =~ s/\r\n$//; | |
21 #print "h=[$header]\n"; | |
22 #print "b=[$body]\n"; | |
23 unless ($header =~ /\bname=([\"']?)(.*?)\1/) { | |
24 next; | |
25 } | |
26 $name = $2; | |
27 #print "name=$name\n"; | |
28 if ($header =~ /filename=(['\"]?)(.*?)\1/ && $2 gt "") { | |
12 | 29 $fn=$2; |
30 if ($fn =~ /^([^\/]*)$/) { | |
31 $fn = $1; | |
32 } | |
660
347ea2bca687
Force remove spaces in filename
HIROSE Yuuji <yuuji@gentei.org>
parents:
12
diff
changeset
|
33 $fn =~ s/ /_/g; |
716
07863b13e3f9
TEST: Extract basename of filename= argument of CGI params.
HIROSE Yuuji <yuuji@gentei.org>
parents:
660
diff
changeset
|
34 $fn =~ s,.*[/\\],,; |
11 | 35 open(OUT, ">$dir/$fn"); |
36 print OUT $body; | |
37 close(OUT); | |
38 printf("%s:filename=%s\n", $name, unpack("H*", $fn)); | |
39 } else { | |
40 printf("%s=%s\n", $name, unpack("H*", $body)); | |
41 } | |
42 } |