diff --git a/mail/extensions/openpgp/test/unit/rnp/test_strip.js b/mail/extensions/openpgp/test/unit/rnp/test_strip.js index 7b6878a2a1..de1c30d7a0 100644 --- a/mail/extensions/openpgp/test/unit/rnp/test_strip.js +++ b/mail/extensions/openpgp/test/unit/rnp/test_strip.js @@ -15,6 +15,9 @@ const { EnigmailKeyRing } = ChromeUtils.import( const { OpenPGPTestUtils } = ChromeUtils.import( "resource://testing-common/mozmill/OpenPGPTestUtils.jsm" ); +const { MailStringUtils } = ChromeUtils.import( + "resource:///modules/MailStringUtils.jsm" +); const keyDir = "../../../../../test/browser/openpgp/data/keys"; @@ -80,3 +83,62 @@ add_task(async function testStripSignatures() { // The imported stripped key should have only the self signature. Assert.equal(sigs[0].sigList.length, 1); }); + +add_task(async function testKeyWithUnicodeComment() { + let keyFile = do_get_file( + `${keyDir}/key-with-utf8-comment.asc` + ); + let keyBlock = await IOUtils.readUTF8(keyFile.path); + + let errorObj = {}; + let fingerPrintObj = {}; + let result = await EnigmailKeyRing.importKeyAsync( + null, + false, + keyBlock, + false, + null, + errorObj, + fingerPrintObj, + false, + [], + false, + false + ); + Assert.equal(result, 0); + + let fpr = "72514F43D0060FC588E80238852C55E6D2AFD7EF"; + let foundKeys = await RNP.getKeys(["0x" + fpr]); + + Assert.equal(foundKeys.length, 1); +}); + +add_task(async function testBinaryKey() { + let keyFile = do_get_file( + `${keyDir}/key-binary.gpg` + ); + let keyData = await IOUtils.read(keyFile.path); + let keyBlock = MailStringUtils.uint8ArrayToByteString(keyData); + + let errorObj = {}; + let fingerPrintObj = {}; + let result = await EnigmailKeyRing.importKeyAsync( + null, + false, + keyBlock, + true, + null, + errorObj, + fingerPrintObj, + false, + [], + false, + false + ); + Assert.equal(result, 0); + + let fpr = "683F775BA2E5F0ADEBB29697A2D1B914F722004E"; + let foundKeys = await RNP.getKeys(["0x" + fpr]); + + Assert.equal(foundKeys.length, 1); +}); diff --git a/mail/test/browser/openpgp/data/keys/key-binary.gpg b/mail/test/browser/openpgp/data/keys/key-binary.gpg new file mode 100644 index 0000000000..3d99fc04c1 Binary files /dev/null and b/mail/test/browser/openpgp/data/keys/key-binary.gpg differ diff --git a/mail/test/browser/openpgp/data/keys/key-with-utf8-comment.asc b/mail/test/browser/openpgp/data/keys/key-with-utf8-comment.asc new file mode 100644 index 0000000000..5006f29196 --- /dev/null +++ b/mail/test/browser/openpgp/data/keys/key-with-utf8-comment.asc @@ -0,0 +1,15 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Comment: 💌 (unicode symbol: love letter) +Comment: 😀 (unicode symbol: smiley) + +mDMEY4d9vRYJKwYBBAHaRw8BAQdAhoLFPAnuWEK0GKQqJfZLeIMJ8mzzo0Bxm47G +04P6qHC0H3Rlc3QgPHRlc3QtdW5pY29kZUBleGFtcGxlLmNvbT6IkwQTFggAOxYh +BHJRT0PQBg/FiOgCOIUsVebSr9fvBQJjh329AhsDBQsJCAcCAiICBhUKCQgLAgQW +AgMBAh4HAheAAAoJEIUsVebSr9fvSqIA/1I5cpEa2UdGGKVXndz3HFoUq5TrRVZd +1el8bq177HbaAQDkJlNvBxwcjW3yDVo4+nxoqm8nK1b8yPwQet2NXobcArg4BGOH +fb0SCisGAQQBl1UBBQEBB0CqqMW7jKUygeB9+DmqMWBoWPZXiSLe4imAGj3t+h/c +JgMBCAeIeAQYFggAIBYhBHJRT0PQBg/FiOgCOIUsVebSr9fvBQJjh329AhsMAAoJ +EIUsVebSr9fvRbwA/ApVf9/S9YjFEcR74W/R5G+PVaL15ERHfiR0f7AYqDgiAPsG +N+POP/0TWKb+uT/jz2QYhjxbdQsELGvWQePLhOb0Aw== +=pPjp +-----END PGP PUBLIC KEY BLOCK-----