Jason Lindquist (jlindquist) wrote,
Jason Lindquist
jlindquist

Bandage for MySpace mail misbehavior

Look, we all know the people responsible for designing and running MySpace are a bunch of douchebags. This isn't just me bitching, it's my opinion as an experienced, professional software developer. The people that make that system go should never be allowed near a keyboard--unless it's being used to beat them. Looking at just their mail notifications, here's the three brain-dead things they do that make it difficult to manage their mail:

One: They MIME-encode headers per RFC-1522 when it's not neccessary. Look, fuckers, if the charset is US-ASCII or ISO-8859-1, LEAVE IT BE. Many non-GUI tools will decode the Subject: header if it's done like this, but they don't do From: or Reply-To:. So all I get in mutt's directory view is a bunch of messages from =?iso-8859-1?q?.

Two: The message body is either text/plain or text/html. Whee. By definition, that's 7-bit ASCII and is passable by any standards-compliant mail transport engine. But MySpace MIME encodes it anyways.

Three: Once decoded? Those message bodies use CR-LF line terminators. Pick one, cockbandits! (If they base64 encode the bodies, at least mimencode can auto-convert them. It won't do it to quoted-printable bodies, though.

No, the "easy solution" of ignoring MySpace isn't feasible. Sadly, I still have too many people I need to keep in touch with who can't break the habit.


Here's the recipe to strip the encoding out of the headers:

### Strip quoted-printable headers

:0
* ^From:.*=\?[^?]+\?[qb]\?[^?]+\?=.*
{
  MYSUBJECT = `formail -c -xFrom: | mimeheaddecode`

  :0 fh
  | $FORMAIL -t -IFrom: -A"From: $MYSUBJECT"
}

:0
* ^Subject:.*=\?[^?]+\?[qb]\?[^?]+\?=.*
{
  MYSUBJECT = `formail -c -xSubject: | mimeheaddecode`

  :0 fh
  | $FORMAIL -t -ISubject: -A"Subject: $MYSUBJECT"
}

:0
* ^Reply-To:.*=\?[^?]+\?[qb]\?[^?]+\?=.*
{
  MYSUBJECT = `formail -c -xReply-To: | mimeheaddecode`

  :0 fh
  | $FORMAIL -t -IReply-To: -A"Reply-To: $MYSUBJECT"
}


mimeheaddecode is a perl script found in $PATH borrowed from Alex Benenson:
#!/usr/local/bin/perl

while (<>) {
  chomp;
  s/^[ \t]//;
  foreach (split(/(=[?].*?[?][BQ][?].*?[?]=)/i)) {
    if (($charset, $encoding, $txt) = /=[?](.*?)[?]([bq])[?](.*?)[?]=/i) {
      $encoding =~ tr/[BQ]/[bq]/;
      open PIPE, "echo '$txt' | mimencode -u -$encoding |";
      $_ = ;
      close PIPE;
      chomp;
      }
    s/[[:^ascii:]]//g;
    print $_;
  }
}


I added the 4th line from the end, which strips all non-ASCII characters, since mimencode's output is 8-bit.

The last recipe takes care of decoding the bodies, straight out of the procmailex(5) manpage:
### Decode quoted-printable and base64 text bodies
### MySpace likes to send this shit.  What a fucking waste.

:0
* ^Content-Type: *text/(plain|html)
{
  :0 fbw
  * ^Content-Transfer-Encoding: *quoted-printable
  | mimencode -u -q -p

     :0 Afhw
     | formail -I "Content-Transfer-Encoding: 8bit"

  :0 fbw
  * ^Content-Transfer-Encoding: *base64
  | mimencode -u -b -p

     :0 Afhw
     | formail -I "Content-Transfer-Encoding: 8bit"
}
Tags: also cocks, intarwebs, myspace, procmail
Subscribe

  • Aurora reference

    For reference, the only two links I could find on Aurora shooter (and Westview '06 grad) James Holmes, prior to his attendance at Westview being…

  • Your friend, FunnyJunk.com

    If you've never heard of funnyjunk.com, it's run by a content thief. It's a haven for incompetence, stupidity, and douchebaggery. Site owner…

  • X-header crap

    It is ridiculous how big this section of my .muttrc has gotten. Every goddamned special snowflake mailer has to have its own collection of…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments