🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #164843

[slrn,vim,slang] help with mimegpg macro

#164843
From: Troy Piggins
Date: Sat, 02 Apr 2005 23:40
111 lines
4972 bytes
I am trying to write, or possibly hack an existing, macro that
detects a mime-gpg signed post and removes the lines that slrn
hasn't handled properly.  Unfortunately I have never written slang
before.

My question has a couple of parts - one to do with vim, but mostly
slang and slrn (versions in sig).

Background is from this post on the n.s.r group :
http://tinyurl.com/627bl

I have tried Tomasz Sienicki's macros with no success.  I thought I
would read his code, and try to use the parts of it that detect the
mime boundaries etc to serve my purposes.  When I started going
through the code, I noticed something odd with the brackets around
line 68 of his code from here:

http://cvs.pld-linux.org/cgi-bin/cvsweb/slrn-pl/macros/tsca-mymime.sl?rev=1.11

If I put the cursor on the first of the curly braces on line 68
which begins :
%{{{ multipart message

and in vim hit the '%' key, which should move the cursor to the
matching closing brace, it actually moves to a closing curly brace
on line 136.  Odd, because it isn't even a comment brace set.

On line 72 there appears to be an opening brace that is not closed,
and I thought this was the problem.  I inserted a closing curly
brace, and '%' then correctly matched the brace sets as expected.

But when I run slrn with the macro modified by me with the extra
brace, it exits with syntax error.  With the unmodified braces it
runs fine.

Any explanations?

So I started a macro of my own (refer below), commented so you
hopefully understand my intentions.  The hide_mimegpg function is
the one I am having trouble with not knowing how to finish.  In the
comments, for my own convenience, I have included while writing some
of the lines in posts that I want to remove so I know the format of
them.  I would think this simple for someone competent in slang (I
am not).  Note that I know this macro does not actually /treat/ the
mime correctly, simply removes it for my viewing pleasure.

Any help/comments appreciated.

% Refer RFC 2015, RFC 3156.
% This macro does note make slrn understand mime-gpg
% it just hides the boundary shit.

private variable c_type = extract_displayed_article_header
("Content-Type");

define hide_mimegpg ()
{
  variable hvr,len,bndry;

  % extract the boundary:
  %  Content-Type: multipart/signed;
  %  boundary="=_mimegpg-commodore.email-scan.com-31974-1112227567-0007";
  %  micalg=pgp-sha1;
  %  protocol="application/pgp-signature"
  (hvr,len) = string_match_nth(1); % not sure if we need another
string_match
                                   % here
  bndry = substr(c_type,hvr+1,len);

  % then locate the boundary in post, which is after the "--":
  %  --=_mimegpg-commodore.email-scan.com-31974-1112227567-0007

  % then remove lines before the first boundary to just after
  % headers:
  %  This is a MIME GnuPG-signed message.  If you see this text, it
  %  means that
  %  your E-mail or Usenet software does not support MIME signed
  %  messages.
  % is it right to remove stuff before the boundary?

  % then remove the whole paragraph of all occurrences of the
  % boundary:
  %  --=_mimegpg-commodore.email-scan.com-31974-1112227567-0007
  %  Content-Type: text/plain; format=flowed; charset="US-ASCII"
  %  Content-Disposition: inline
  %  Content-Transfer-Encoding: 7bit

  %  --=_mimegpg-commodore.email-scan.com-31974-1112227567-0007
  %  Content-Type: application/pgp-signature
  %  Content-Transfer-Encoding: 7bit

  % then remove lines after the last boundary which also ends in
  % "--":
  %  --=_mimegpg-commodore.email-scan.com-31974-1112227567-0007--

}

define read_article_hook ()
{
  % determine if post contains mimegpg - header begins:
  %  Content-Type: multipart/signed; boundary......
  if (string_match(c_type,"\\Cmultipart/signed",1))
    hide_mimegpg ();
}

Thanks
-- 
T R O Y  P I G G I N S
e : usenet@piggo.com
[slrn 0.9.8.1, slang and slang-devel 1.4.5-16.rpm, and vim 6.1]
Technical Details
Message-ID: <slrnd4ubbi.q1n.usenet@piggo.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.editors.mbox.zip!g2news1.google.com!news3.google.com!news.glorb.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!uunet!dca.uu.net!snewsf0.syd.ops.aspac.uu.net!news1.optus.net.au!optus!newsfeeder.syd.optusnet.com.au!news.optusnet.com.au!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <slrnd4ubbi.q1n.usenet@piggo.com>
Subject: [slrn,vim,slang] help with mimegpg macro
Date: Sat, 02 Apr 2005 23:40:34 +0000
From: Troy Piggins <usenet@piggo.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.editors.mbox.zip!g2news1.google.com!news3.google.com!news.glorb.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!uunet!dca.uu.net!snewsf0.syd.ops.aspac.uu.net!news1.optus.net.au!optus!newsfeeder.syd.optusnet.com.au!news.optusnet.com.au!not-for-mail
Newsgroups: news.software.readers,comp.editors,alt.lang.s-lang
Reply-To: usenet@piggo.com
Followup-To: news.software.readers
Mail-Copies-To: usenet@piggo.com
User-Agent: slrn/0.9.8.1 (Linux)
Lines: 110
NNTP-Posting-Host: 210.49.65.93
X-Trace: 1112485234 5399 210.49.65.93