(#2708) - implement attachment stub length

Also non-stubs don't have a length value. Added a bunch of tests to test various cases, including PNGs, plaintext, and empty plaintext.