phpas2 icon indicating copy to clipboard operation
phpas2 copied to clipboard

Severe file size limitation and (obsolete) folded headers

Open ghaecker opened this issue 3 years ago • 1 comments

Thank you for your work on this library.

Are you open to a pull request to address a couple of issues I've found?

File Size Limitation

This library is being tested at work for receiving large file transfers from a business partner. Some of the files are nearly 50M. Everything works fine on small files. In my set of 24 test files, the largest successful transfer with the unmodified library was 174K. The next size up is 545K. It failed, as did all the other larger files.

I've identified the cause for the failure in 2 key methods: Utils::parseMessage (called by MimePart::fromString) and MimePart::setBody. In both cases, the culprit seems to be an inability of preg_match and preg_split to handle large subject arguments. They silently fail to return matches that succeed with the same patterns used with smaller strings.

I've rewritten both methods using strpos() to solve this limitation. It succeeds now with a 46M test file.

Obsolete Header Folding

AS2 messages from our business partner at work arrive with long header values folded to the next line with a leading horizontal tab. Even though they're POSTing via HTTP 1.1 and shouldn't be using obs-fold we still have to preserve them, because they are in the decrypted content and are included in MIC calculation.

I have an ugly kludge in place now in CryptoHelper, but I'm working on a more elegant solution in parseMessage.

Anyway, I appreciate the work you've done. It's been helpful. I'd like to contribute some of what I've found and solved if you're open to it.

--Glenn

ghaecker avatar Mar 08 '21 11:03 ghaecker