Re: repairing the From: headers of sed-users ...

"Cameron Simpson [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 01Jan2015 13:50, eliana <[email protected]> wrote:
>> On 01Jan2015 09:27, Cameron Simpson <[email protected]> wrote:
>> >As I'm sure you're all aware, Yahoo Groups began mangling our From:
>> >headers last year to be from the list, not the author, because Yahoo
>> >moved to DKIM validation. [...]
>> >This sed script is here:
>> > https://bitbucket.org/cameron_simpson/css/src/tip/bin/fix-dkim-from
>> >will under to From: header, producing a correct original author. [...]
>
>I am having trouble with the first y command.  Note that I have changed the list name and list server as this should fit any mailing list that uses DKIM, from what I see in your script itself:
>
>bash# echo 'From: "Sender Name [email protected]" <[email protected]>' | sed -f fix-dkim-from.sed
>sed: file fix-dkim-from.sed line 61: strings for `y' command are different lengths

First up, if you make the script executable (chmod a+rx fix-dkim-from.sed) you 
can run it directly; it has a suitable #! line.

And PLEASE, run this as an ordinary user, not root! (The sed script itself is 
ok, as it does not write any files, but as general practice...)

>bash# grep -w y fix-dkim-from.sed
>  y/    / /
>  y/\n/ /
>bash#
>
>Any idea what I am doing wrong, or what is wrong with my copy of the script?  I just quoted the From line above as an example, I get the same error message when I do:

The first y/// has a literal TAB character. You may need to specially type it.

>cat email/filename | sed -f fix.dkim-from.sed
>
>I did have trouble navigating bitbucket, and ended up printing a copy of the html page.

The "RAW" link should get you the pure text of the script.

>Then I went back and got the gzip version of the script, and when I run that as above, there is no error, but I get no output, whether I just echo the From line, or process the whole email.

It is important that the script only gets the message header. It does not leave 
message bodies alone.

>Is that because the first line of the script is:
>
>#!/usr/bin/sed -nf
>
>When I remove the -nf, I still get no output??  As in, the script runs quietly and all I see as the result is a bash prompt.

That is strange. The script requires the -n option, as it uses its own "p" 
commands to emit the lines after processing.

Please try downloading the file directly from the bitbucket "RAW" link and see 
if it works for you. I have tested it with both OSX sed (BSD sed) and GNU sed.

One other thing. because the script (a) gathers lines into the hold space 
before processing and (b) has a command that acts on "$" (the last line) the 
output the output for each line is delayed until the next line is received (or 
EOF reached). So if you're working on this interactively there will be a delay.

You might be best off copying a message header into a file an testing:

  ./fix-dkim-from < testfile.txt

Cheers,
Cameron Simpson <[email protected]>

Strong typing isn't for weak minds; the argument 'strong typing is for weak
minds' is for weak minds. - Guy Harris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.