Repository navigation
Escape feed-controlled data in Telegram HTML messages - #2251
Merged
Merged
Conversation
- Add escapeHtml utility for HTML-safe output in Telegram messages (URLs, raw data) - Use sanitize() consistently for titles (escapes HTML + normalizes whitespace) - Fix unescaped URLs in send.ts feed item links (href and fallback text) - Fix unescaped URLs in sub-multi-url.ts subscription success messages - Fix unescaped URLs in import-from-opml.ts import success messages - Fix unescaped URLs in rss.ts feed lists (raw and viewAll modes) - Add comprehensive tests for HTML escaping and whitespace normalization (28 tests) Readability improvements: - Enhanced documentation clarifying when to use escapeHtml() vs sanitize() - Extracted repeated expressions into clear local variables - Added clarifying comments at output-building call sites - Organized tests with descriptive nested describe blocks Behavior changes: - Special characters (&, <, >, ", ') in URLs and titles are now escaped - Feed titles and OPML outline text have whitespace normalized (newlines removed, spaces collapsed) - Plain inputs without special characters or extra whitespace produce identical output Co-authored-by: fengkx <liangkx8237@gmail.com>
cursor
Bot
force-pushed
the
cursor/fix-html-escaping-7548
branch
from
October 22, 2026 08:13
f4d5bc0 to
9847b75
Compare
fengkx
marked this pull request as ready for review
October 22, 2026 08:15
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes HTML escaping in Telegram messages to prevent feed-controlled and user-controlled data from breaking message formatting or being misinterpreted as HTML markup.
Rebased onto master after PR #2250 merge (commit 358ca54). Both changes now work together: notification templates use fixed EJS templates with escaped locals (PR #2250), while feed item messages escape URLs and sanitize titles (this PR).
Changes
New utility
source/utils/escape-html.ts: HTML escape helper for URLs and raw data that preserves exact formatting (wrapsescapeHTMLfrom fast-escape-html)Consistent function usage
escapeHtml()for URLs and raw data (escapes HTML, preserves whitespace)sanitize()for titles and content (escapes HTML + normalizes whitespace by removing newlines and collapsing spaces)Fixed locations
item.linkin href attributes and when used as fallback link text (when title is empty)Readability improvements
escapeHtml()(URLs/raw data) vssanitize()(titles/content)Testing
&,<,>,",'Total test suite: 19 suites, 116 tests (all passing)
Behavior Changes
&,<,>,",') in URLs and titles are now escaped and display literally in TelegramIntegration with PR #2250
templateLocalsparameter tosend()function - no conflictssource/index.ts- this PR doesn't touch those paths