Fetch icon indicating copy to clipboard operation
Fetch copied to clipboard

Issue with multi-dimensional structure->parts

Open M1ke opened this issue 11 years ago • 4 comments

Whilst parsing a message which contains an embedded image for someone's signature I came across an issue which caused the entire message including plain, html and base64 image parts to be stored in the $plaintextMessage property. A dump of the full $this->structures object is shown below.

I have managed to solve it by adding a new method loadMessageParts() which recursively supplies structures to the processStructure() method. It also chains the $partIdentifier value which works correctly with imap_fetchbody(). See my multipart-fix branch

It might be that I've misunderstood use of the system and this fix isn't needed, as nobody else seems to be reporting a similar issue. Please post if this is the case or more information is needed on my issue or fix. If it seems the issue is valid I can ensure the code is formatted properly and submit a pull request.

The structure is as follows:

stdClass Object
(
    [type] => 1
    [encoding] => 0
    [ifsubtype] => 1
    [subtype] => ALTERNATIVE
    [ifdescription] => 0
    [ifid] => 0
    [ifdisposition] => 0
    [ifdparameters] => 0
    [ifparameters] => 1
    [parameters] => Array
        (
            [0] => stdClass Object
                (
                    [attribute] => BOUNDARY
                    [value] => ------------040407080008060204020006
                )
        )
    [parts] => Array
        (
            [0] => stdClass Object
                (
                    [type] => 0
                    [encoding] => 0
                    [ifsubtype] => 1
                    [subtype] => PLAIN
                    [ifdescription] => 0
                    [ifid] => 0
                    [lines] => 23
                    [bytes] => 400
                    [ifdisposition] => 0
                    [ifdparameters] => 0
                    [ifparameters] => 1
                    [parameters] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [attribute] => CHARSET
                                    [value] => UTF-8
                                )
                            [1] => stdClass Object
                                (
                                    [attribute] => FORMAT
                                    [value] => flowed
                                )
                        )
                )
            [1] => stdClass Object
                (
                    [type] => 1
                    [encoding] => 0
                    [ifsubtype] => 1
                    [subtype] => RELATED
                    [ifdescription] => 0
                    [ifid] => 0
                    [ifdisposition] => 0
                    [ifdparameters] => 0
                    [ifparameters] => 1
                    [parameters] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [attribute] => BOUNDARY
                                    [value] => ------------070800070803000004020103
                                )
                        )
                    [parts] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [type] => 0
                                    [encoding] => 0
                                    [ifsubtype] => 1
                                    [subtype] => HTML
                                    [ifdescription] => 0
                                    [ifid] => 0
                                    [lines] => 43
                                    [bytes] => 1594
                                    [ifdisposition] => 0
                                    [ifdparameters] => 0
                                    [ifparameters] => 1
                                    [parameters] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [attribute] => CHARSET
                                                    [value] => UTF-8
                                                )
                                        )
                                )
                            [1] => stdClass Object
                                (
                                    [type] => 5
                                    [encoding] => 3
                                    [ifsubtype] => 1
                                    [subtype] => PNG
                                    [ifdescription] => 0
                                    [ifid] => 1
                                    [id] => <part2.08030200.00000802@REDACTED>
                                    [bytes] => 63816
                                    [ifdisposition] => 0
                                    [ifdparameters] => 0
                                    [ifparameters] => 0
                                    [parameters] => stdClass Object
                                        (
                                        )
                                )
                        )
                )
        )
)

M1ke avatar Dec 02 '14 15:12 M1ke

You want to make a pull request so we can see how it's doing with unit tests and everything?

tedivm avatar Dec 02 '14 17:12 tedivm

I've not written anything extra into the tests; I wanted to know if it seemed like a valid issue and a sensible fix before doing anything further. I've tried to run the tests but get an error about a file in /tmp.

M1ke avatar Dec 02 '14 17:12 M1ke

I can only know if it's a valid fix if it doesn't break anything else. If you issue a pull request then travis ci will run the test suite against your code to make sure there are no regressions.

tedivm avatar Dec 02 '14 17:12 tedivm

Any change you've had another chance to look over the unit tests? I'm a bit concerned about test coverage here.

tedivm avatar Mar 09 '15 06:03 tedivm