Skip to content

Preserve HTML in generic payload services - #1602

Open
cyphercodes wants to merge 1 commit into
caronc:masterfrom
cyphercodes:fix-generic-html-payloads
Open

Preserve HTML in generic payload services#1602
cyphercodes wants to merge 1 commit into
caronc:masterfrom
cyphercodes:fix-generic-html-payloads

Conversation

@cyphercodes

Copy link
Copy Markdown

Summary

  • add supported-format selection for services that can pass through multiple body formats
  • mark custom JSON/Form/XML payload services as text+HTML pass-through so HTML input is not converted to text unless ?format= explicitly overrides it
  • add regressions for generic JSON/Form/XML HTML payloads

Fixes #1600

Tests

  • PYTHONPATH=. pytest tests/test_plugin_custom_json.py tests/test_plugin_custom_form.py tests/test_plugin_custom_xml.py
  • PYTHONPATH=. ruff check apprise/apprise.py apprise/plugins/base.py apprise/plugins/custom_json.py apprise/plugins/custom_form.py apprise/plugins/custom_xml.py tests/test_plugin_custom_json.py tests/test_plugin_custom_form.py tests/test_plugin_custom_xml.py
  • git diff --check

@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3ab3ee9) to head (d7d5191).
⚠️ Report is 76 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1602   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          205       205           
  Lines        28213     28228   +15     
  Branches      4659      4660    +1     
=========================================
+ Hits         28213     28228   +15     
Files with missing lines Coverage Δ
apprise/apprise.py 100.00% <100.00%> (ø)
apprise/plugins/base.py 100.00% <100.00%> (ø)
apprise/plugins/custom_form.py 100.00% <100.00%> (ø)
apprise/plugins/custom_json.py 100.00% <100.00%> (ø)
apprise/plugins/custom_xml.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@caronc caronc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The scope of this (using this approach) expands far beyond just the 3 plugins in question. Email plugins are text/html, i think Telegram is markdown/html (i forget), but Slack and many of the other plugins all support multiple outputs purely governed by the ?format= switch at this time... Code like this would all need to align with auto-assignments based on the input (if provided) otherwise fall back to how it already acts today.

The scope may be even larger than this, i need to think more about the problem.

Comment thread apprise/plugins/base.py
Comment on lines 203 to +208
notify_format = NotifyFormat.TEXT

# Supported Notify Formats. When more than one value is provided, the
# first remains the default unless a matching input format can be passed
# through without conversion.
notify_formats = ()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think there is more to it unfortunately then just adding the pluralized version of notify_format while leaving the old. This is a bit of a breaking change.

This significantly impacts the apprise.details() call which allows upstream systems who've adapted to a very consistent JSON dump to build/manipulate based on a well defined schema for the past 8 years... It would have to adapt to this... I use this output very extensively to dynamically provide URL Generation on the fly here.

This might be an opportunity to rebuild this part of the code properly but in a special branch we call release-v2 since it will introduce breaking changes?

image_size = NotifyImageSize.XY_128

# Preserve supported input formats for pass-through payloads
notify_formats = (NotifyFormat.TEXT, NotifyFormat.HTML)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think the idea of these custom formats would be to pass along everything untouched but just escaped correctly (respectfully.. .like xml:// would have < and > tags and proper encoding, while json:// would be sure to escape " and anything else required to pack the string in a JSON string.... This would apply to markdown as well which isn't identified here or any of the other plugins using your approach (which i'm still not too sure about yet). I think we should debate a bit more in the other thread.

@caronc

caronc commented May 7, 2026

Copy link
Copy Markdown
Owner

On a side note; fantastic job remaining backwards compatible! I love that all of the tests passed! Well done 🚀 .

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.

Give plugins access to the originally submitted body_format, so generic plugins can pass it through

2 participants