Re: X-Commands in body longer than 72-80 characters?
Peter, the only criticism I have of this method is that it requires the person sending the X-Command to know in advance that it's going to be wrapped, and to put the magic "_END" at the end of this. This was not my situation; the X-Commands just suddenly stopped working (for only long email addresses, we discovered later) and no one knew why. I prefer a solution which says: "X-Commands, if they appear in the body of a message, must be the first line, and must be followed by a blank line before the rest of the body of the message, or be the only thing in the message. If there's more than one X-Command in the body, they must not be separated by a blank line." I think that this would work more intuitively and naturally. It should also work for automatic word wrapping which occurs without the author's knowledge or consent. Unfortunately, I don't know how to write the perl code for this. Sorry. Thank you for your efforts to update the FAQ. I've found it very valuable. -Kevin Zembower
Peter Hartzler <pete@hartzler.net> 07/18/02 07:59PM >>> Hmm...
I'm interested in updating the FAQ, but the code seems to be a bit crazy yet. (Ironically, the word-wrapping doesn't help. ;-) Now, I could be way off on this one, so don't go jumping up to place this into production; there are some dark corners to this stuff that I'm sure I don't know about! If the goal here is to pick out and unwrap text from a message and inject that text as a header using perl, then I'm thinking this might be saner: --- cut here --- # Allow embedding a single X-Command on multiple lines # within the body of an email. (Lines will be joined.) # Look for FIRST magic X_CMD: token. If found, # take from there to __END and add to message header. # Like this: X_CMD: X-Command: blah blah blah __END # (X-Command: blah blah blah..) can be across multiple lines... # Note that this is kind of expensive, but X-Commands should # be somewhat rare. :0 Bw * X_CMD: * __END { XCMD=`perl -p -0077 -e \ 's/[\n\r\s]+/ /sg; \ s/^.*?X_CMD:\s*(.*?)\s*__END.*/$1/;'` :0 f |formail -i "$XCMD" } # End of recipe --- cut here --- Please let me know if I'm out to lunch on this one. Check out the SmartList FAQ at http://www.hartzler.net/smartlist/ Regards, Pete. _______________________________________________ Smartlist mailing list Smartlist@lists.RWTH-Aachen.DE http://MailMan.RWTH-Aachen.DE/mailman/listinfo/smartlist
E. Kevin Zembower wrote, | I prefer a solution which says: | "X-Commands, if they appear in the body of a message, must be the first | line, and must be followed by a blank line before the rest of the body | of the message, or be the only thing in the message. If there's more | than one X-Command in the body, they must not be separated by a blank | line." Oh, you want to allow two or more X-Command: lines at the top of the body; I didn't realize that part. | Unfortunately, I don't know how to write the perl code for this. You don't need to. I've already posted a solution that doesn't use perl, but I'll modify it: :0B # password needs to come before line break * $ ^^X-Command:(.*\<)?$password { :0Bfw # brackets enclose caret, space, tab; note space left of ampersand * ^^(.+$)+[^ ] | sed -e '/^$/,$ b' -e '/^[^ ]*:/b' -e 's/^[^ ]/ &/' :0hfw | formail -X '' # two apostrophes with nothing between } Of course, if someone decides to send it multipart and the first thing in the body is MIME-wrapping instead of the sender's typed text, all bets are off.
Kevin -- After reading David Tamkin's post I'm going to have to unearth my sed book; sed's man pages and info pages are all quite lame... So... More Perl!!! ;-) Ah, I was thrown off by the "X_COMMAND" and "__END" tokens somewhere in this thread. Here is what I come up with -- not that there is a shortage of good solutions -- I'm mainly just enjoying hacking on it. FWIW, This could be easily hacked to allow X-Commands to start on *any* body line, not just the first, which would deal with MIME lossage... (ick) Aaaaanyhow, unless there's a good reason, I promise to stop flogging this expired equine. After this last time. --- cut here --- # X-Commands, if they appear in the body of a message, # must be the first line, and must be followed by a # blank line before the rest of the body of the message, # or be the only thing in the message. If there's more # than one X-Command in the body, they must not be # separated by a blank line. # Each X-Command: must start at the beginning of a line. # Each X-Command: blah blah blah can be across multiple lines. # This is expensive, but X-Commands should be somewhat rare. :0 Bw * ^^X-Command:.* { # Perl in slurp/print mode; # Zap header; # Zap secondary paras; # flatten to one line; # put each cmd on own line: XCMD=`perl -p -0077 -e \ 's/.*?[\n\r]{2,}//s; \ s/[\n\r]{2,}.*//s; \ s/[\n\r\s]+/ /sg; \ s/ (X-Command:)/\n$1/g;'` :0 af * XCMD ?? ^X-Command: .+ |formail -i "$XCMD" } # End of recipe --- cut here --- Regards, Pete. On Fri, 19 Jul 2002, KEVIN ZEMBOWER wrote:
Peter, the only criticism I have of this method is that it requires the person sending the X-Command to know in advance that it's going to be wrapped, and to put the magic "_END" at the end of this. This was not my situation; the X-Commands just suddenly stopped working (for only long email addresses, we discovered later) and no one knew why.
I prefer a solution which says: "X-Commands, if they appear in the body of a message, must be the first line, and must be followed by a blank line before the rest of the body of the message, or be the only thing in the message. If there's more than one X-Command in the body, they must not be separated by a blank line."
I think that this would work more intuitively and naturally. It should also work for automatic word wrapping which occurs without the author's knowledge or consent.
Unfortunately, I don't know how to write the perl code for this. Sorry.
Thank you for your efforts to update the FAQ. I've found it very valuable.
-Kevin Zembower
Peter Hartzler <pete@hartzler.net> 07/18/02 07:59PM >>> Hmm...
I'm interested in updating the FAQ, but the code seems to be a bit crazy yet. (Ironically, the word-wrapping doesn't help. ;-)
Now, I could be way off on this one, so don't go jumping up to place this into production; there are some dark corners to this stuff that I'm sure I don't know about!
If the goal here is to pick out and unwrap text from a message and inject that text as a header using perl, then I'm thinking this might be saner:
--- cut here --- # Allow embedding a single X-Command on multiple lines # within the body of an email. (Lines will be joined.) # Look for FIRST magic X_CMD: token. If found, # take from there to __END and add to message header. # Like this: X_CMD: X-Command: blah blah blah __END # (X-Command: blah blah blah..) can be across multiple lines... # Note that this is kind of expensive, but X-Commands should # be somewhat rare. :0 Bw * X_CMD: * __END { XCMD=`perl -p -0077 -e \ 's/[\n\r\s]+/ /sg; \ s/^.*?X_CMD:\s*(.*?)\s*__END.*/$1/;'`
:0 f |formail -i "$XCMD" } # End of recipe --- cut here ---
Please let me know if I'm out to lunch on this one.
Check out the SmartList FAQ at http://www.hartzler.net/smartlist/
Regards,
Pete.
Smartlist mailing list Smartlist@lists.RWTH-Aachen.DE http://MailMan.RWTH-Aachen.DE/mailman/listinfo/smartlist
Pete Hartzler wrote, | After reading David Tamkin's post I'm going to have to unearth my sed | book; sed's man pages and info pages are all quite lame... So... So was my sed code; what was I thinking? (Brackets enclose caret, space, tab, as usual.) | sed -e '2,/^$/ !b' -e '/^[^ ][^ ]*:/! s/./ &/' or if you like braces in your sed code, | sed -e '2,/^$/{' -e '/^[^ ][^ ]*:/! s/./ &/' -e '}' Adding more indentation to a line that is already indented is harmless and not worth coding around. Also, if you want to allow only X-Command: at the top of the body and not any other additional lines for the headers, replace the two bracketed groups and the asterisk after them (but keeping the anchoring caret ahead of them) with "X-Command" (sans quotes).
participants (3)
-
David W. Tamkin
-
KEVIN ZEMBOWER
-
Peter Hartzler