Skip to content

fix: allow single-character inline image content IDs - #151

Open
pcbeingused33 wants to merge 1 commit into
mailersend:mainfrom
pcbeingused33:fix/inline-content-id-c3485
Open

pcbeingused33 wants to merge 1 commit into
mailersend:mainfrom
pcbeingused33:fix/inline-content-id-c3485

Conversation

@pcbeingused33

Copy link
Copy Markdown

Single-character image content IDs currently produce attachment disposition rather than inline, so an HTML reference such as cid:x cannot use the intended inline image.

Both setImage and AddImageFromFile require the trimmed content ID length to exceed one, although their documented contract only requires a nonempty ID. Accept a trimmed length greater than zero in both methods, preserving null, empty and whitespace-only handling.

Testing and validation

Added 12 parameterized cases covering both image setters with single-character, longer, padded, null, empty and whitespace-only IDs. The tests check serialized disposition as well as ID, filename and base64 content. On main, four cases fail; with this change, all 12 pass under Java 11 using JUnit Jupiter. These tests use a local temporary file and make no API calls.

This change and its tests were generated with assistance from OpenAI Codex.

@mailerlite-kritika

Copy link
Copy Markdown

Re-runViewConfidence Score: 5/5

[Low risk] The change only lowers the trimmed content ID threshold from greater than one to greater than zero in setImage and AddImageFromFile, so null, empty and whitespace-only IDs still produce attachment disposition. It moves no dependency, and the added test covers both setters' serialized disposition, so the risk rests on a small behavioral change in one class.

Summary

Lets single-character content IDs produce inline disposition for image attachments

Both setImage and AddImageFromFile in Attachment.java now treat a trimmed content ID of length greater than zero as inline, which matches their Javadoc ("set and not empty"). Null, empty and whitespace-only IDs still give attachment. The new AttachmentTest serializes the object with Gson to check the disposition field.

What's good

  • The tests cover both setters with the same boundary cases: single-character, padded, null, empty and whitespace-only IDs.
  • The tests check the serialized disposition, not just the Java field, and use a temp directory with no API calls.
Review context · 0/5 commands
  • Commands run: none

Reviews (1) · Last reviewed commit: "fix: allow single-character inline image..." · claude-sonnet-5-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant