Add HTML string escape and unescape APIs#13408
Draft
bneradt wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a reusable HTML escaping implementation in tscore and exposes it to plugins via the new TSStringHtmlEscape TSAPI function, with unit + gold-test coverage and API documentation (per #13331).
Changes:
- Add
Encoding::html_escape()core implementation and Catch2 unit tests. - Add new public plugin API
TSStringHtmlEscape()and document it. - Add a gold-test plugin + replay test verifying escaping in a response transform.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/gold_tests/pluginTest/tsapi/test_TSStringHtmlEscape.test.py | Adds an ATS replay-based gold test driver that deploys the new test plugin. |
| tests/gold_tests/pluginTest/tsapi/test_TSStringHtmlEscape.replay.yaml | Defines replay transactions validating response-body escaping behavior end-to-end. |
| tests/gold_tests/pluginTest/tsapi/test_TSStringHtmlEscape.cc | Implements a response-transform test plugin that calls TSStringHtmlEscape(). |
| tests/gold_tests/pluginTest/tsapi/CMakeLists.txt | Builds the new autest plugin. |
| src/tscore/unit_tests/test_Encoding.cc | Adds Catch2 coverage for Encoding::html_escape() behavior and error handling. |
| src/tscore/Encoding.cc | Implements Encoding::html_escape() and associated helpers. |
| src/api/InkAPI.cc | Adds the TSStringHtmlEscape() TSAPI wrapper calling into Encoding::html_escape(). |
| include/tscore/Encoding.h | Exposes the new Encoding::html_escape() declaration. |
| include/ts/ts.h | Adds the TSStringHtmlEscape() API declaration (and a new mode constant). |
| doc/developer-guide/api/functions/TSStringHtmlEscape.en.rst | Documents the new TSAPI function and usage guidance. |
bneradt
force-pushed
the
html-escape-api
branch
3 times, most recently
from
July 20, 2026 16:48
eab989c to
72f8da9
Compare
bneradt
force-pushed
the
html-escape-api
branch
2 times, most recently
from
July 20, 2026 17:11
bff922d to
ad1da66
Compare
ATS does not provide reusable HTML escaping helpers to core components or plugins. This adds paired escape and unescape helpers, exposes them through the plugin API, and covers both directions with unit and replay tests. Escaping follows the WHATWG fragment serialization algorithm. Fixes: apache#13331
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 adds reusable core HTML escaping and unescaping helpers and the
TSStringHtmlEscape and TSStringHtmlUnescape plugin APIs. The escaping
behavior follows the WHATWG fragment serialization algorithm:
https://html.spec.whatwg.org/#escapingString
Fixes: #13331