├── .eslintignore ├── index.js ├── .gitignore ├── test ├── data │ ├── basic1 │ ├── charsets │ ├── shift-jis-image │ ├── multipart4 │ ├── base64-2 │ ├── multipart1 │ ├── multipart-base64-3 │ ├── multipart-base64-1 │ ├── multipart-base64-2 │ ├── multipart-binary │ ├── multipart2 │ ├── multipart3 │ ├── base64-1 │ ├── multipart-addresses │ ├── multipart-addresses-groups │ ├── message-encoded │ ├── multipart-empty-attachment │ ├── multipart-complex1 │ ├── multipart-encrypted-subject-utf8 │ ├── multipart-content-id │ ├── multipart-complex2 │ ├── multipartmalt-detach │ ├── bug505221 │ └── bugmail11 ├── test_custom_headers.js ├── test_structured_header_emitters.js ├── utils.js ├── test_mail_parser.ts ├── test_structured_headers.js ├── test_header_emitter.js └── test_mime_tree.js ├── lib ├── jsmime.js ├── textDecoders.js ├── utils.js ├── structuredHeaders.js ├── mailParser.js └── headerEmitter.js ├── .github ├── dependabot.yml └── workflows │ └── tests.yml ├── docs ├── Developing.mkd └── RelatedSpecifications.mkd ├── index.d.ts ├── LICENSE ├── package.json ├── .eslintrc.json ├── karma.conf.js └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | index.d.ts -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | export { parseMail } from './lib/mailParser'; 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | test/.DS_Store 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /test/data/basic1: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset=iso-8859-1 2 | 3 | Hello, world! 4 | -------------------------------------------------------------------------------- /test/data/charsets: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protonmail/jsmimeparser/main/test/data/charsets -------------------------------------------------------------------------------- /test/data/shift-jis-image: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/protonmail/jsmimeparser/main/test/data/shift-jis-image -------------------------------------------------------------------------------- /test/data/multipart4: -------------------------------------------------------------------------------- 1 | Content-Type: multipart/mixed; boundary=boundary 2 | 3 | --boundary 4 | 5 | This has no headers, so should be recognized as plain text. 6 | 7 | --boundary-- 8 | -------------------------------------------------------------------------------- /lib/jsmime.js: -------------------------------------------------------------------------------- 1 | export { default as MimeParser } from './rawMimeParser'; 2 | export { default as headerparser } from './headerParser'; 3 | import * as headeremitter from './headerEmitter'; 4 | 5 | export { headeremitter }; 6 | -------------------------------------------------------------------------------- /test/data/base64-2: -------------------------------------------------------------------------------- 1 | Content-Type: text/html; encoding=iso-8859-1 2 | Content-Transfer-Encoding: base64 3 | 4 | PGh0bWw+PGJvZHk+VGhpcyBpcyBiYXNlNjQgZW5jb2RlZCBIVE1MIHRleHQsIGFuZCB0aGUgdGFncyB 5 | zaG91bGRuJ3QgYmUgc3RyaXBwZWQuDQo8Yj5Cb2xkIHRleHQgaXMgYm9sZCE8L2I+PC9ib2R5PjwvaH 6 | RtbD4NCg== 7 | -------------------------------------------------------------------------------- /test/data/multipart1: -------------------------------------------------------------------------------- 1 | Content-Type: multipart/mixed; 2 | boundary="boundary" 3 | 4 | This is a text message in MIME format. 5 | This part shouldn't appear in the output. 6 | 7 | --boundary 8 | Content-Type: text/plain 9 | 10 | Hello, world! (yet again...) 11 | 12 | --boundary-- 13 | -------------------------------------------------------------------------------- /test/data/multipart-base64-3: -------------------------------------------------------------------------------- 1 | Content-Type: multipart/mixed; boundary=boundary 2 | 3 | etc etc 4 | --boundary 5 | Content-Type: text/html 6 | Content-Transfer-Encoding: base64 7 | 8 | PGh0bWw+PGhlYWQ+VGhpcyB0aW1lLCB0aGUgdGFncw0Kc2hvdWxkIGJlIHN0cmlwcGVkIG91dC48L2hlYWQ+PC9odG1sPg== 9 | 10 | --boundary-- 11 | -------------------------------------------------------------------------------- /test/data/multipart-base64-1: -------------------------------------------------------------------------------- 1 | Content-Type: multipart/mixed; boundary=boundary 2 | Content-Transfer-Encoding: base64 3 | 4 | This part shouldn't appear 5 | --boundary 6 | Content-Type: text/plain 7 | Content-Transfer-Encoding: base64 8 | 9 | TXVsdGlwYXJ0IGJhc2U2NCBlbmNvZGVkIHRleHQu 10 | 11 | --boundary-- 12 | -------------------------------------------------------------------------------- /test/data/multipart-base64-2: -------------------------------------------------------------------------------- 1 | Content-Type: multipart/mixed; boundary=boundary 2 | 3 | yadda yadda 4 | 5 | --boundary 6 | Content-Type: text/html 7 | Content-Transfer-Encoding: base64 8 | 9 | PGh0bWw+PGhlYWQ+YmFzZTY0ZW5jb2RlZCBIVE1MIHRleHQgaW5zaWRlIGEgbXVsdGlwYXJ0IG1lc3N 10 | hZ2UuPC9oZWFkPjwvaHRtbD4= 11 | 12 | --boundary-- 13 | -------------------------------------------------------------------------------- /test/data/multipart-binary: -------------------------------------------------------------------------------- 1 | Subject: binary attachment 2 | Content-Type: multipart/mixed; boundary="vungrzvzr" 3 | 4 | --vungrzvzr 5 | Content-Type: text/plain; 6 | Content-Transfer-Encoding: 8bit 7 | 8 | see binary attachment 9 | 10 | --vungrzvzr 11 | Content-Type: application/octect-stream 12 | Content-Transfer-Encoding: binary 13 | 14 | 15 | --vungrzvzr-- 16 | -------------------------------------------------------------------------------- /test/data/multipart2: -------------------------------------------------------------------------------- 1 | Content-Type: multipart/mixed; boundary=boundary 2 | 3 | This is a text/html message. This part shouldn't appear at all! 4 | 5 | --boundary 6 | Content-Type: text/html 7 | 8 |
Multipart HTML message with just a single part! 9 | 10 | 11 | --boundary-- 12 | 13 | Actually, this part shouldn't appear either. 14 | -------------------------------------------------------------------------------- /test/data/multipart3: -------------------------------------------------------------------------------- 1 | Content-Type: multipart/mixed; boundary=boundary 2 | 3 | --boundary 4 | Content-Type: text/html 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Here, the HTML tags should be stripped out. 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | --boundary-- 30 | -------------------------------------------------------------------------------- /test/data/base64-1: -------------------------------------------------------------------------------- 1 | Content-Type: text/plain; charset=iso-8859-1 2 | Content-Transfer-Encoding: base64 3 | 4 | DQpIZWxsbywgd29ybGQhIChBZ2Fpbi4uLikNCg0KTGV0J3Mgc2VlIGhvdyB3ZWxsIGJhc2U2NCB0ZXh 5 | 0IGlzIGhhbmRsZWQuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFlheSwgbG90cyBvZiBzcGFjZX 6 | MhIFRoZXJlJ3MgZXZlbiBhIENSTEYgYXQgdGhlIGVuZCBhbmQgb25lIGF0IHRoZSBiZWdpbm5pbmcsI 7 | GJ1dCB0aGUgb3V0cHV0IHNob3VsZG4ndCBoYXZlIGl0Lg0K 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "npm" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | allow: 8 | - dependency-name: "playwright" 9 | versioning-strategy: increase 10 | ignore: 11 | - dependency-name: "playwright" 12 | update-types: ["version-update:semver-patch"] # patches do not include browser version updates 13 | -------------------------------------------------------------------------------- /docs/Developing.mkd: -------------------------------------------------------------------------------- 1 | Developing 2 | ========== 3 | 4 | JSMime is intended to rely only on HTML 5 Web APIs and ES 6 as external 5 | requirements for its development. However, these are still a work in progress, 6 | and thus support for them may vary from browser to browser or among different 7 | rendering engines. Polyfilling may be necessary to get this to work, but 8 | polyfills should only be present in test framework code and not in the main source or test files themselves. 9 | -------------------------------------------------------------------------------- /test/data/multipart-addresses: -------------------------------------------------------------------------------- 1 | From: Some One