🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #181684

Re: [Dialog] Split header into multiple line?

#181684
From: Korbinian Abenthum
Date: Mon, 13 Mar 2006 01:52
87 lines
5164 bytes
Korbinian Abenthum wrote:

> Ah! An even more hazardous idea: Just put the whole body into the header,
> typing it in with the X-Headers-Textbox is pretty cumbersome after all.
>
> May the usenet goddess fogive me, bbhhh.

And that would be the script. For this one I take absolutely no
responsibility. I tried to make it as safe as I could, but if it messes up
and you loose your usenet account for posting technically broken articels,
don't come complaining :)

If you use it, Eggs, and want the *complete* body to be put into a folded
header, put the trigger (and the trigger only) into the first line of your
article, and it will happen.

Use it wisely.

----8<------------

const PAIH_TRIGGER = 'PAIH'; //If first line of body equals that (case sensitive), the answer is put into the body
const PAIH_HEADER = 'X-Answer: '; //Case sensitive! The name of the header to fold
const PAIH_FOLDING_WHITEPACE = '	'; //Text at the beginning of every folded line. Has to start with either a space or a tab.
const PAIH_NEW_BODY_CONTENT = 'Answer is in the header'; //For the mortals, a little hint what's going on.

const PAIH_MAXINT = 2147483647;

function HasInvalidCharacters(st:String):boolean;
var i:integer;
begin
  for i := 1 to length(st) do begin
    if (ord(st[i])<32) OR (ord(st[i])>127) then begin
      result := true;
      exit;
    end;
  end;
  result := false;
end;

//It is imperative that the result of this method is checked and respected!
//we do mess with the article, and simply quit if we encounter an error
//that leaves the article in an undefined state, and it should not be processed
//any further, and must not be sent out!
function PutAnswerIntoHeader(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
var i : integer;
    foundBody : boolean;
begin
  if ((Copy(PAIH_FOLDING_WHITEPACE, 1, 1)<>chr(32)) AND (Copy(PAIH_FOLDING_WHITEPACE, 1, 1)<>chr(9))) then begin result:=false; exit; end; //Misconfiguration.

  result:=true; //we only fail if we find non-ascii in the body.
  
  foundBody := false;
  //For all lines of the article
  for i:=0 to Message.count-1 do begin
    if (not foundBody) and (message.strings[i]='') then begin
      foundBody := true;
      if ((i>=Message.count-1) OR (message.strings[i+1]<>PAIH_TRIGGER)) then exit; //First body line did not containg trigger
      
      message.delete(i); //remove the header-body-seperator
      message.delete(i); //remove the trigger
            
      if (i>=Message.count) then begin
        message.insert(message.count, ''); //new seperator
        exit; //No more body!
      end;

      if (HasInvalidCharacters(message.strings[i])) then begin result:=false; exit; end;
      message.strings[i] := PAIH_HEADER + message.strings[i];
      continue;
    end;
    
    if (not foundBody) then continue;

    if (HasInvalidCharacters(message.strings[i])) then begin result:=false; exit; end;
    message.strings[i] := PAIH_FOLDING_WHITEPACE + message.strings[i];
  end; //for
  
  message.insert(message.count, ''); //new seperator
  if (Length(PAIH_NEW_BODY_CONTENT)>0) then message.insert(message.count, PAIH_NEW_BODY_CONTENT);
end;


-- 
"Brothers, oh brothers, my days here are done,
 the Dornishman's taken my life,
 But what does it matter, for all men must die,
 and I've tasted the Dornishman's wife!"
Technical Details
Message-ID: <130306.025205.nsr.106@news.abenthum.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeedt0.toon.t-online.de!62.153.159.134.MISMATCH!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail
References: <44koior92p7o$.dlg@sneupie.eingang.org> <pan.2006.03.12.17.27.48.163479@thurston.blinkynet.net> <ch635j2vxv1x.dlg@sneupie.eingang.org> <pan.2006.03.12.18.00.08.838753@thurston.blinkynet.net> <1y2mzdbcin47z.dlg@sneupie.eingang.org> <pan.2006.03.12.19.24.19.631550@thurston.blinkynet.net> <6q77pqpnyaoq$.dlg@sneupie.eingang.org> <slrne18vrk.6as.pjr@nntp.alcatroll.com> <1hc408k.g6n6bb1ygp9bmN%snipe@spambin.fsnet.co.uk> <130306.022727.nsr.104@news.abenthum.de>

Show Full Headers
Complete Article Headers
Message-ID: <130306.025205.nsr.106@news.abenthum.de>
Subject: Re: [Dialog] Split header into multiple line?
Date: Mon, 13 Mar 2006 02:52:05 +0100
From: Korbinian Abenthum <korbinian@gmx.de>
References: <44koior92p7o$.dlg@sneupie.eingang.org> <pan.2006.03.12.17.27.48.163479@thurston.blinkynet.net> <ch635j2vxv1x.dlg@sneupie.eingang.org> <pan.2006.03.12.18.00.08.838753@thurston.blinkynet.net> <1y2mzdbcin47z.dlg@sneupie.eingang.org> <pan.2006.03.12.19.24.19.631550@thurston.blinkynet.net> <6q77pqpnyaoq$.dlg@sneupie.eingang.org> <slrne18vrk.6as.pjr@nntp.alcatroll.com> <1hc408k.g6n6bb1ygp9bmN%snipe@spambin.fsnet.co.uk> <130306.022727.nsr.104@news.abenthum.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeedt0.toon.t-online.de!62.153.159.134.MISMATCH!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail
Newsgroups: news.software.readers
Organization: T-Online
Lines: 87
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.t-online.com 1142214956 02 22936 YH8BvBaL4STiQEz 060313 01:55:56
X-Complaints-To: usenet-abuse@t-online.de
X-ID: GhCVlqZf8eegwSxz1Um3-E+1lCJv8IY-HVvSDEb9yK5x31ibAAsHEH
X-Now-Playing: Ennio Morricone - once upon a time in america
User-Agent: 40tude_Dialog/2.0.15.35 Hamster/2.1.0.5
X-Face: &[gF$*:|'M7pwKut]{LOz!&65BT96:Wn\M"V6Qa#q%~9^z8XhJfmh?.)VB{,
 p]Z`6q@e()!g1ghrG7.atG.DXfzulkKE%u~|D7?e6^-yN4GvZJuvz%$LZBA6`dJTo,
 MYUO%I*0us[.v/AT,