TL;DR: This PR adds some updates to make sure that 1) Cypress attachments are mimicking actual browser behavior and 2) we validate pdf headers on the front end just like we do on the back end.
This PR addresses two things
1) PDFs with incorrect headers were accepted on the front end but rejected on the back end. While there might be slight differences between front-end and back-end validation, this was a particularly large and unnecessary difference.
2) The validation in the original PR for 10001 et al. correctly caught that corrupt-pdf is corrupt in the Cypress test but did not catch it outside of Cypress. This was because we attached files in Cypress with a different encoding than what occurs in the browser. (More details: in Cypress, because the file was loaded with a non-binary encoding, pdfjs happened to fail to parse the PDF and therefore marked it as corrupt. Outside of Cypress, where the file bytes were loaded as a binary array, pdfjs happened to be able to parse the PDF and therefore did not mark it as corrupt. To avoid this divergence between the test environment and actual environment, I defaulted to uploading files in Cypress via binary encoding.)
TL;DR: This PR adds some updates to make sure that 1) Cypress attachments are mimicking actual browser behavior and 2) we validate pdf headers on the front end just like we do on the back end.
This PR addresses two things
1) PDFs with incorrect headers were accepted on the front end but rejected on the back end. While there might be slight differences between front-end and back-end validation, this was a particularly large and unnecessary difference. 2) The validation in the original PR for 10001 et al. correctly caught that corrupt-pdf is corrupt in the Cypress test but did not catch it outside of Cypress. This was because we attached files in Cypress with a different encoding than what occurs in the browser. (More details: in Cypress, because the file was loaded with a non-binary encoding, pdfjs happened to fail to parse the PDF and therefore marked it as corrupt. Outside of Cypress, where the file bytes were loaded as a binary array, pdfjs happened to be able to parse the PDF and therefore did not mark it as corrupt. To avoid this divergence between the test environment and actual environment, I defaulted to uploading files in Cypress via binary encoding.)