fix: escape reserved XML prompt tags in sanitizeContent - #1691
Open
Juwan-Hwang wants to merge 1 commit into
Open
fix: escape reserved XML prompt tags in sanitizeContent#1691Juwan-Hwang wants to merge 1 commit into
Juwan-Hwang wants to merge 1 commit into
Conversation
ashwin-ant
previously approved these changes
Aug 19, 2026
Juwan-Hwang
force-pushed
the
fix/escape-reserved-prompt-tags
branch
from
August 19, 2026 02:48
eb64866 to
cdbbb4b
Compare
Contributor
Author
|
Rebased onto main and resolved merge conflicts in test/sanitizer.test.ts. Ready for re-approval and merge! |
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.
Summary
This PR enhances prompt boundary formatting and robustness by escaping reserved XML prompt delimiter tags (such as
</pr_or_issue_body>,</trigger_comment>,<context>, etc.) in user-supplied content withinsanitizeContent.Problem & Motivation
claude-code-actionrelies on XML-style tags to delimit external untrusted content (PR bodies, issue comments, reviews) within the prompt constructed for Claude.When external content contains raw XML closing or opening tags that match reserved prompt structure delimiters (either inadvertently in discussions/code snippets or deliberately), it can prematurely close container tags and disrupt the prompt's intended context boundary and structure.
Changes
escapePromptTagsinsrc/github/utils/sanitizer.ts:formatted_context,pr_or_issue_body,trigger_comment,custom_instructions,context,metadata, etc.).<and>to<and>for those specific reserved tags while preserving non-reserved HTML tags and hyphenated custom identifiers (e.g.,<div class="...">,<context-sensitive>).normalizeHtmlEntitiesto ensure entity-encoded variations (e.g.</trigger_comment>) are safely neutralized.test/sanitizer.test.ts:sanitizeContent.Verification
test/sanitizer.test.tsverifying all patterns and edge cases.