Skip to content

Fix: Convert img tags to markdown to prevent '>' appearing in posts#131

Merged
hanzei merged 1 commit intomattermost-community:masterfrom
Alearner12:fix/issue-70-image-blockquote
Dec 23, 2025
Merged

Fix: Convert img tags to markdown to prevent '>' appearing in posts#131
hanzei merged 1 commit intomattermost-community:masterfrom
Alearner12:fix/issue-70-image-blockquote

Conversation

@Alearner12
Copy link
Copy Markdown
Contributor

Summary

Fixes #70

When an image is attached in a Bitbucket issue description, the > (blockquote) character was appearing in Mattermost posts.

Problem

  • Bitbucket sends images as <img> HTML tags in issue/comment descriptions
  • The replaceAllBitBucketUsernames function strips HTML tags using doc.Text()
  • Empty lines left by stripped <img> tags would show > characters after the quote function was applied

Solution

Added handling for <img> tags in the replaceAllBitBucketUsernames function that converts them to markdown image syntax (![alt](src)) before text extraction. This ensures:

  • Images are properly displayed in Mattermost posts
  • No orphan > blockquote characters appear

#Changes

  • server/templaterenderer/template.go - Added img tag to markdown conversion
  • server/templaterenderer/template_fixture_test.go - Added test fixture for issues with images
  • server/templaterenderer/issue_test.go - Added test case for image handling

Testing

  • All existing tests pass
  • Added new test RenderIssueCreatedEventNotificationForSubscribedChannels_WithImage

…attermost-community#70)

When an image is attached in a Bitbucket issue description, the HTML
contains <img> tags. Previously, these were stripped by doc.Text(),
potentially leaving empty lines that would show as '>' blockquote
characters in Mattermost posts after the quote function was applied.

This fix converts <img> tags to markdown image syntax (![alt](src))
before extracting text, ensuring images are properly displayed in
Mattermost and preventing orphan '>' characters from appearing.

- Added handling for img tags in replaceAllBitBucketUsernames function
- Added test case for issues with image attachments
- Added test fixture for issue with image content
@mattermost-build
Copy link
Copy Markdown

Hello @Alearner12,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

Per the Mattermost Contribution Guide, we need to add you to the list of approved contributors for the Mattermost project.

Please help complete the Mattermost contribution license agreement?
Once you have signed the CLA, please comment with /check-cla and confirm that the CLA check is green.

This is a standard procedure for many open source projects.

Please let us know if you have any questions.

We are very happy to have you join our growing community! If you're not yet a member, please consider joining our Contributors community channel to meet other contributors and discuss new opportunities with the core team.

@Alearner12
Copy link
Copy Markdown
Contributor Author

/check-cla

Copy link
Copy Markdown
Collaborator

@hanzei hanzei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one 👍

@hanzei hanzei merged commit 6c3078e into mattermost-community:master Dec 23, 2025
3 checks passed
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.

When i attach image in the issue Description then in the mattermost post i can see the '>' icon in the Post.

3 participants