osTicket/osTicket-1.8 — pull request #492 by greezybacon (2014-01-29 04:49:43+00:00)
Title: oops: Fix finding key of existing file

If a file is attached via email and sent into the system, and a file is on record with the same signature (hash) and size, the system will not save the file. Instead, the key of the existing file would be found and used instead.

This patch fixes a bug in AttachmentFile::save. The key was generated for the new file; however, if it was determined to be a duplicate, the key of the existing file was not returned. Therefore generated key, which wasn't saved to the database, was returned. Therefore, the wrong key was placed in the body of the message with cid: for inline images, although that key would not exist in the database.

This patch correctly returns the existing key from the ::save() method for de-duplicated files.