Eml-to-pdf bug fixes: removal of incompatible fonts, removal of emoji in favor of @, jakarta-mail dependency handling improvements#3770
Conversation
…l fonts and improve attachment marker handling by removing emoji that might not interpreted by some systems.
…only-general-fonts
…characters that is more visiable
…only-general-fonts
…only-general-fonts
…only-general-fonts
… processing in EmlToPdf
…only-general-fonts
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the EmlToPdf utility to address inline image processing, replace unsupported emoji representations with an "@" marker, and improve Jakarta Mail dependency handling for enhanced email-to-PDF conversion.
- Updates style and MIME constants to simplify font and attachment marker management
- Enhances inline image processing, logging, and reflection-based constructor usage
- Refactors attachment and multipart processing with additional Jakarta Mail type checks
Comments suppressed due to low confidence (2)
common/src/main/java/stirling/software/common/util/EmlToPdf.java:1693
- The original EmojiPositionFinder constructor declared throwing IOException due to PDFTextStripper's constructor. Verify that removing the throws clause in AttachmentMarkerPositionFinder does not lead to unhandled IO issues or compilation errors with PDFBox.
public AttachmentMarkerPositionFinder() {
common/src/main/java/stirling/software/common/util/EmlToPdf.java:183
- Changing validateEmlInput to no longer throw IOException (and instead relying on IllegalArgumentException) could affect callers expecting IO-related exceptions. Confirm that downstream error handling is adjusted accordingly.
private static void validateEmlInput(byte[] emlBytes) {
common/src/main/java/stirling/software/common/util/EmlToPdf.java
Outdated
Show resolved
Hide resolved
|
what is it missing that causes the Jakarta Mail libraries to be missing? what system dep? |
|
I do think that the font was my own fault, but Jakarta Mail problem was partly missing version.properties. I added better fallback to this, and kind more explicit checks. I tried to be more explicit in how the especially the content part handled e.g in processMultipartAdvanced/Image handling just in case and that seem to solve the other part of it. In my testing, when I added logging there it seemed like it wasn't even called or reached by the code when in docker. Not 100% sure why. Anyhow, I spent considerable time testing this with all sorts of edge cases, and I am confident about this. |
|
Do you think it would be wise to add junit Test to this? I think that would levitate some concerns , and making emails for testing that would fail without proper dependencies wouldn't be that hard. But I didn't check this beforehand so this is just a guess. |
…pointConfiguration
|
JUnits are welcome to add but not a requirement for the repo, although we should start requiring that tbf... |
|
Makes sense. I wouldn't mix Junit test with this per se, but I'll work on that then. Sorry for inconvenience on this. |
|
Ill merge this code as is, junits can be separate |
Description of Changes
This pull request introduces enhancements and code cleanup to the
EmlToPdfutility class, focusing on improving email-to-PDF conversion, handling embedded images, and simplifying the codebase. Key changes include better handling of inline images, enhanced Jakarta Mail dependency checks, and refactoring for improved readability and maintainability.Enhancements to Email-to-PDF Conversion:
cid:references) by converting them into data URIs for proper inline display.Attachment Handling Enhancements:
iconor 📎 emoji) with a new marker (@) for consistency across the application (non-fat images did not support the emoji, however @ is supported accross the board.)AttachmentMarkerPositionFinderinstead ofEmojiPositionFinder, aligning with the new attachment marker system.Jakarta Mail Dependency Handling:
Code Cleanup and Refactoring:
StyleConstants,MimeConstants,FileSizeConstants) by removing unnecessary constructors and unused constants.Checklist
General
Documentation
UI Changes (if applicable)
Testing (if applicable)