RACC and YACC problem in TMail

Hello all,

I am trying to get outlook email through a small set of programs I
wrote to download/modify/and upload emails.

Problem is, TMail seems to not be handling the Microsoft outlook
Content-Type header declaration, specifically:

Content-Type: multipart/alternative;
boundary=----=_NextPart_000_0093_01C81419.EB75E850

Where as it can handle the Apple mail (and others) for example:

Content-Type: multipart/alternative; boundary=Apple-Mail-27–96051287

Works fine.

What TMail does to the outlook ones is simply delete them. This
produces broken email streams, sometimes running two emails into each
other.

Below is the test case and an ugly hack fix, but the summary is that
TMail is parsing the boundary=(.*)$ and is choking on the second ‘=’.

So I wrote some tests to show this failing with 2 to 4 = signs in the
text to the right of boundary=

diff -r tmail-0.10.8/test/testheader.rb tmail-0.10.9/test/testheader.rb
574a575,593

assert_equal 1, h.params.size
assert_equal '----=_=NextPart_000_0093_01C81419.EB75E850', h.params['boundary']

h = TMail::HeaderField.new('Content-Type', 'multipart/alternative; boundary=----=_=NextPart_000_0093_01C81419=EB75E850')
assert_equal 'multipart', h.main_type
assert_equal 'alternative', h.sub_type
assert_equal 1, h.params.size
assert_equal '----=_=NextPart_000_0093_01C81419=EB75E850', h.params['boundary']

Then I dug through the source code and found the following in a RACC
file:

        | params ';' TOKEN '=' value
            {
              val[0][ val[2].downcase ] = val[4]
              val[0]
            }

Now… I knew NOTHING of YACC or RACC before tonight… so I started
googling etc.

But the only solution I came up with is this:

diff -r tmail-0.10.8/lib/tmail/parser.y tmail-0.10.9/lib/tmail/parser.y
286a287,304

              val[0]
            }
        | params ';' TOKEN '=' value '=' value '=' value '=' value
          {
            l = val.length
            val[0][ val[2].downcase ] = val[4..l].join
            val[0]
          }

The above code makes all the test cases pass but is totally ugly, and a
hack.

What I WANT to be able to say is:

params ‘;’ TOKEN ‘=’ and_anything_to_end_of_line
{
val[0][ val[2].downcase ] = val[4]
val[0]
}

Are there any YACC / RACC people out there that can provide a cleaner
solution so I can send a real fix to the maintainer of TMail?

Thanks,

Mikel

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs