From 72f72d64a422d6628c4796f5c0bf2e508f134214 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:05:14 +0900 Subject: Adding upstream version 0.5.1 --- scripts/multipart/.cvsignore | 2 + scripts/multipart/Makefile.in | 75 +++++++++ scripts/multipart/README | 24 +++ scripts/multipart/mailcap | 1 + scripts/multipart/multipart.cgi.in | 313 +++++++++++++++++++++++++++++++++++++ 5 files changed, 415 insertions(+) create mode 100644 scripts/multipart/.cvsignore create mode 100644 scripts/multipart/Makefile.in create mode 100644 scripts/multipart/README create mode 100644 scripts/multipart/mailcap create mode 100644 scripts/multipart/multipart.cgi.in (limited to 'scripts/multipart') diff --git a/scripts/multipart/.cvsignore b/scripts/multipart/.cvsignore new file mode 100644 index 0000000..db1dff2 --- /dev/null +++ b/scripts/multipart/.cvsignore @@ -0,0 +1,2 @@ +multipart.cgi +Makefile diff --git a/scripts/multipart/Makefile.in b/scripts/multipart/Makefile.in new file mode 100644 index 0000000..ad472ee --- /dev/null +++ b/scripts/multipart/Makefile.in @@ -0,0 +1,75 @@ +@SET_MAKE@ +SHELL=@SHELL@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +DOMAIN = $(PACKAGE) +srcidr=@srcdir@ +top_srcdir=@top_srcdir@ +VPATH= $(srcdir):. +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +datadir = @datadir@ +libdir = @libdir@ +includedir = @includedir@ +infodir = @infodir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +top_srcdir = @top_srcdir@ +VPATH = $(top_srcdir):. +DESTDIR = + +CGIBIN_DIR = $(libexecdir)/$(PACKAGE)/cgi-bin +AUXBIN_DIR = $(libexecdir)/$(PACKAGE) +HELP_DIR = @HELP_DIR@ +RC_DIR = @RC_DIR@ +ETC_DIR = $(sysconfdir) +CONF_DIR = $(sysconfdir)/$(PACKAGE) + +LIB_TARGETS = multipart.cgi + +MKDIR = mkdir -p +INSTALL = @INSTALL@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ + +PERL = @PERL@ +NKF = @NKF@ + +all: $(LIB_TARGETS) + +# do nothing +$(LIB_TARGETS): + +install: $(LIB_TARGETS) + -$(MKDIR) $(DESTDIR)$(CGIBIN_DIR) + for file in $(LIB_TARGETS); \ + do \ + $(INSTALL_SCRIPT) $$file $(DESTDIR)$(CGIBIN_DIR); \ + done + +uninstall: + -for file in $(LIB_TARGETS); \ + do \ + rm -f $(CGIBIN_DIR)/$$file; \ + done + +clean: + +distclean: + -rm -f $(LIB_TARGETS) + -rm -f Makefile + +dist: all + @-rm -fr $(distdir)/multipart + $(MKDIR) $(distdir)/multipart + cp Makefile README multipart.cgi.in $(distdir)/multipart + ( cd $(distdir); tar -cf - multipart | GZIP='' gzip ) \ + > $(distdir)/multipart.tar.gz + -rm -fr $(distdir)/multipart + diff --git a/scripts/multipart/README b/scripts/multipart/README new file mode 100644 index 0000000..b82f585 --- /dev/null +++ b/scripts/multipart/README @@ -0,0 +1,24 @@ + +Content-Type: multipart/* を扱う local-CGI + + Content-Type: multipart/* なファイルを扱うための local-CGI です。 + 主に mailx などでメールを PAGER="w3m -m" で読む場合を想定しています。 + +インストール + + * make install + 必要なら PERL, NKF, LIBDIR を設定してください。 + + * mailcap を ~/.w3m/mailcap にマージ + multipart.cgi のパスに注意 + + * w3m の Option Setting Panel で、 + 『保存時に Content-Transfer-Encoding をデコードする』を ON + 添付ファイルの保存時に便利です。 + +必要なもの + + * NKF モジュールまたは nkf + 文字コード変換や MIME ヘッダのデコードにを使ってます。 + 気にいらなければ変えてください。 + diff --git a/scripts/multipart/mailcap b/scripts/multipart/mailcap new file mode 100644 index 0000000..323ee20 --- /dev/null +++ b/scripts/multipart/mailcap @@ -0,0 +1 @@ +multipart/*; /usr/local/lib/w3m/multipart.cgi %s %{boundary}; htmloutput diff --git a/scripts/multipart/multipart.cgi.in b/scripts/multipart/multipart.cgi.in new file mode 100644 index 0000000..db8001c --- /dev/null +++ b/scripts/multipart/multipart.cgi.in @@ -0,0 +1,313 @@ +#!@PERL@ + +eval "use NKF;"; +if (! $@) { + $use_NKF = 1; + $CONV = "-e"; + $MIME_DECODE = "-m -e"; +} else { + $use_NKF = 0; +# $CONV = "w3m -dump -e"; + $CONV = "@NKF@ -e"; + $MIME_DECODE = "@NKF@ -m -e"; +} +$MIME_TYPE = "$ENV{'HOME'}/.mime.types"; + +$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0; +$CGI = "file://$SCRIPT_NAME"; + +if ($ENV{'REQUEST_METHOD'} eq 'POST') { + sysread(STDIN, $query, $ENV{'CONTENT_LENGTH'}); +} elsif (defined($ENV{'QUERY_STRING'})) { + $query = $ENV{'QUERY_STRING'}; +} +if (defined($query)) { + for (split('&', $query)) { + s/^([^=]*)=//; + $v{$1} = $_; + } + $file = &form_decode($v{'file'}); + $boundary = &form_decode($v{'boundary'}); +} else { + $file = $ARGV[0]; + if (@ARGV >= 2) { + $boundary = $ARGV[1]; + } +} +(-f $file) || exit(1); +open(F, "< $file") || exit(1); +$end = 0; +$mbody = ''; +if (defined($boundary)) { + while() { + s/\r?\n$//; + ($_ eq "--$boundary") && last; + ($_ eq "--$boundary--") && ($end = 1, last); + $mbody .= "$_\n"; + } +} else { + while() { + s/\r?\n$//; + if (s/^\-\-//) { + $boundary = $_; + last; + } + $mbody .= "$_\n"; + } +} + +if (defined($v{'count'})) { + $count = 0; + while($count < $v{'count'}) { + while() { + s/\r?\n$//; + ($_ eq "--$boundary") && last; + } + eof(F) && exit; + $count++; + } + + %header = (); + $hbody = ''; + while() { + /^\s*$/ && last; + $x = $_; + s/\r?\n$//; + if (/=\?/) { + $_ = &decode($_, $MIME_DECODE); + } + if (s/^(\S+)\s*:\s*//) { + $h = $&; + if ($h =~ /^w3m-control/i) { + $h = "WARNING: $h"; + } + $hbody .= "$h$_\n"; + $p = $1; + $p =~ tr/A-Z/a-z/; + $header{$p} = $_; + } elsif (s/^\s+//) { + chop $hbody; + $hbody .= "$_\n"; + $header{$p} .= $_; + } + } + $type = $header{"content-type"}; + $dispos = $header{"content-disposition"}; + if ($type =~ /application\/octet-stream/) { + if ($type =~ /type\=gzip/) { + print "Content-Encoding: x-gzip\n"; + } + if ($type =~ /name=\"?([^\"]+)\"?/ || + $dispos =~ /filename=\"?([^\"]+)\"?/) { + $type = &guess_type($1); + if ($type) { + print "Content-Type: $type; name=\"$1\"\n"; + } else { + print "Content-Type: text/plain; name=\"$1\"\n"; + } + } + } + print $hbody; + print "\n"; + while() { + $x = $_; + s/\r?\n$//; + ($_ eq "--$boundary") && last; + if ($_ eq "--$boundary--") { + last; + } + print $x; + } + close(F); + exit; +} + +$qcgi = &html_quote($CGI); +$qfile = &html_quote($file); +$qboundary = &html_quote($boundary); + +if ($mbody =~ /\S/) { + $_ = $mbody; + s/\&/\&/g; + s/\/\>/g; + print "
\n";
+	print $_;
+	print "
\n"; +} + +$count = 0; +while(! $end) { + %header = (); + $hbody = ''; + while() { + /^\s*$/ && last; + s/\r?\n$//; + if (/=\?/) { + $_ = &decode($_, $MIME_DECODE); + } + if (s/^(\S+)\s*:\s*//) { + $hbody .= "$&$_\n"; + $p = $1; + $p =~ tr/A-Z/a-z/; + $header{$p} = $_; + } elsif (s/^\s+//) { + chop $hbody; + $hbody .= "$_\n"; + $header{$p} .= $_; + } + } + $type = $header{"content-type"}; + $dispos = $header{"content-disposition"}; + $plain = 0; + $image = 0; + if (! $dispos || $dispos =~ /^inline/i) { + if (! $type || $type =~ /^text\/plain/i) { + $plain = 1; + } elsif ($type =~ /^image\//i) { + $image = 1; + } + } + $body = ''; + while() { + s/\r?\n$//; + ($_ eq "--$boundary") && last; + if ($_ eq "--$boundary--") { + $end = 1; + last; + } + if ($plain) { + $body .= "$_\n"; + } + } + $| = 1; + print "
\n"; + { + $_ = $hbody; + s/\&/\&/g; + s/\/\>/g; + print "
\n";
+		print $_;
+		print "
\n"; + if ($type =~ /name=\"?([^\"]+)\"?/ || + $dispos =~ /filename=\"?([^\"]+)\"?/) { + $name = $1; + } else { + $name = "Content"; + } + print "
\n"; + print "\n"; + print "\n"; + print "\n"; + if ($image) { + print "\n"; + } else { + print "\n"; + } + print "
\n" + } + if ($plain) { + $body = &decode($body, $CONV); + $_ = $body; + s/\&/\&/g; + s/\/\>/g; + print "
\n\n";
+		print $_;
+		print "
\n"; + } + eof(F) && last; + $count++; +} +close(F); + +sub decode { +if ($use_NKF) { + local($body, $opt) = @_; + return nkf($opt, $body); +} + local($body, @cmd) = @_; + local($_); + + $| = 1; + pipe(R, W2); + pipe(R2, W); + if (! fork()) { + close(F); + close(R); + close(W); + open(STDIN, "<&R2"); + open(STDOUT, ">&W2"); + exec @cmd; + die; + } + close(R2); + close(W2); + print W $body; + close(W); + $body = ''; + while() { + $body .= $_; + } + close(R); + return $body; +} + +sub html_quote { + local($_) = @_; + local(%QUOTE) = ( + '<', '<', + '>', '>', + '&', '&', + '"', '"', + ); + s/[<>&"]/$QUOTE{$&}/g; + return $_; +} + +sub form_decode { + local($_) = @_; + s/\+/ /g; + s/%([\da-f][\da-f])/pack('c', hex($1))/egi; + return $_; +} + +sub form_encode { + local($_) = @_; + s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; + return $_; +} + +sub guess_type { + local($_) = @_; + + /\.(\w+)$/ || return ""; + $_ = $1; + tr/A-Z/a-z/; + %mime_type = &load_mime_type($MIME_TYPE); + $mime_type{$_}; +} + +sub load_mime_type { + local($file) = @_; + local(%m, $a, @b, $_); + + open(M, "< $file") || return (); + while() { + /^#/ && next; + chop; + (($a, @b) = split(" ")) >= 2 || next; + for(@b) { + $m{$_} = $a; + } + } + close(M); + return %m; +} -- cgit v1.2.3 From 6db339b3d7a391f196e7c4b725a4ed0bd00f31cf Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:23:02 +0900 Subject: Adding upstream version 0.5.2 --- scripts/multipart/Makefile.in | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts/multipart') diff --git a/scripts/multipart/Makefile.in b/scripts/multipart/Makefile.in index ad472ee..20af165 100644 --- a/scripts/multipart/Makefile.in +++ b/scripts/multipart/Makefile.in @@ -8,6 +8,7 @@ top_srcdir=@top_srcdir@ VPATH= $(srcdir):. prefix = @prefix@ exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ bindir = @bindir@ datadir = @datadir@ libdir = @libdir@ -- cgit v1.2.3 From 5397d09e585a1938fb64bc9c5cd5daed1959eb90 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:41:45 +0900 Subject: Adding upstream version 0.5.3 --- scripts/multipart/CVS/Entries | 6 ++++++ scripts/multipart/CVS/Repository | 1 + scripts/multipart/CVS/Root | 1 + scripts/multipart/Makefile.in | 1 - 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 scripts/multipart/CVS/Entries create mode 100644 scripts/multipart/CVS/Repository create mode 100644 scripts/multipart/CVS/Root (limited to 'scripts/multipart') diff --git a/scripts/multipart/CVS/Entries b/scripts/multipart/CVS/Entries new file mode 100644 index 0000000..b503f2a --- /dev/null +++ b/scripts/multipart/CVS/Entries @@ -0,0 +1,6 @@ +/.cvsignore/1.2/Mon Sep 22 22:53:53 2003// +/README/1.2/Wed Nov 21 09:21:59 2001// +/mailcap/1.1/Thu Nov 15 00:32:14 2001// +/multipart.cgi.in/1.11/Tue Feb 18 15:26:39 2003// +/Makefile.in/1.6/Tue Jan 4 09:22:28 2011// +D diff --git a/scripts/multipart/CVS/Repository b/scripts/multipart/CVS/Repository new file mode 100644 index 0000000..cb383c6 --- /dev/null +++ b/scripts/multipart/CVS/Repository @@ -0,0 +1 @@ +w3m/scripts/multipart diff --git a/scripts/multipart/CVS/Root b/scripts/multipart/CVS/Root new file mode 100644 index 0000000..121fa06 --- /dev/null +++ b/scripts/multipart/CVS/Root @@ -0,0 +1 @@ +:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/scripts/multipart/Makefile.in b/scripts/multipart/Makefile.in index 20af165..6c7ec6f 100644 --- a/scripts/multipart/Makefile.in +++ b/scripts/multipart/Makefile.in @@ -24,7 +24,6 @@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ top_srcdir = @top_srcdir@ VPATH = $(top_srcdir):. -DESTDIR = CGIBIN_DIR = $(libexecdir)/$(PACKAGE)/cgi-bin AUXBIN_DIR = $(libexecdir)/$(PACKAGE) -- cgit v1.2.3 From 620796f8d750bc58e1cf1327ff54aed32e302c73 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Tue, 22 May 2012 23:06:58 +0900 Subject: Remove garbage files --- scripts/multipart/CVS/Entries | 6 ------ scripts/multipart/CVS/Repository | 1 - scripts/multipart/CVS/Root | 1 - 3 files changed, 8 deletions(-) delete mode 100644 scripts/multipart/CVS/Entries delete mode 100644 scripts/multipart/CVS/Repository delete mode 100644 scripts/multipart/CVS/Root (limited to 'scripts/multipart') diff --git a/scripts/multipart/CVS/Entries b/scripts/multipart/CVS/Entries deleted file mode 100644 index b503f2a..0000000 --- a/scripts/multipart/CVS/Entries +++ /dev/null @@ -1,6 +0,0 @@ -/.cvsignore/1.2/Mon Sep 22 22:53:53 2003// -/README/1.2/Wed Nov 21 09:21:59 2001// -/mailcap/1.1/Thu Nov 15 00:32:14 2001// -/multipart.cgi.in/1.11/Tue Feb 18 15:26:39 2003// -/Makefile.in/1.6/Tue Jan 4 09:22:28 2011// -D diff --git a/scripts/multipart/CVS/Repository b/scripts/multipart/CVS/Repository deleted file mode 100644 index cb383c6..0000000 --- a/scripts/multipart/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/scripts/multipart diff --git a/scripts/multipart/CVS/Root b/scripts/multipart/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/scripts/multipart/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m -- cgit v1.2.3 From 1d0ba25a660483da1272a31dd077ed94441e3d9f Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Sat, 2 Jan 2021 09:20:37 +0900 Subject: New upstream version 0.5.3+git20210102 --- scripts/multipart/.cvsignore | 2 -- scripts/multipart/README | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 16 deletions(-) delete mode 100644 scripts/multipart/.cvsignore (limited to 'scripts/multipart') diff --git a/scripts/multipart/.cvsignore b/scripts/multipart/.cvsignore deleted file mode 100644 index db1dff2..0000000 --- a/scripts/multipart/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -multipart.cgi -Makefile diff --git a/scripts/multipart/README b/scripts/multipart/README index b82f585..ed1f73d 100644 --- a/scripts/multipart/README +++ b/scripts/multipart/README @@ -1,24 +1,24 @@ -Content-Type: multipart/* を扱う local-CGI +Content-Type: multipart/* 宴 local-CGI - Content-Type: multipart/* なファイルを扱うための local-CGI です。 - 主に mailx などでメールを PAGER="w3m -m" で読む場合を想定しています。 + Content-Type: multipart/* <ゃ宴 local-CGI с + 筝祉 mailx с<若 PAGER="w3m -m" ц翫喝障 -インストール +ゃ潟鴻若 * make install - 必要なら PERL, NKF, LIBDIR を設定してください。 + 綽荀 PERL, NKF, LIBDIR 荐絎 - * mailcap を ~/.w3m/mailcap にマージ - multipart.cgi のパスに注意 + * mailcap ~/.w3m/mailcap 若 + multipart.cgi 鴻羈 - * w3m の Option Setting Panel で、 - 『保存時に Content-Transfer-Encoding をデコードする』を ON - 添付ファイルの保存時に便利です。 + * w3m Option Setting Panel с + 篆絖 Content-Transfer-Encoding 潟若 ON + 羞私<ゃ篆絖箴水с -必要なもの +綽荀 - * NKF モジュールまたは nkf - 文字コード変換や MIME ヘッダのデコードにを使ってます。 - 気にいらなければ変えてください。 + * NKF ≪吾ャ若障 nkf + 絖潟若紊 MIME 潟若篏帥c障 + 羂医 -- cgit v1.2.3