> On Jul 22, 2026, at 6:26 PM, Masakazu Kitajo <[email protected]> wrote:
>
> Why should ATS provide this functionality? What's the benefit of having our
> own implementation? Would the addition be worth paying the maintenance cost?
>
> It would make some sense if the API were optimized for TSIOBuffer, TSVIO,
> or something ATS specific, but the function signatures tell that these
> functions could be simply replaced with functions provided by a third party
> library. Nothing needs internal information that can't be accessed by
> plugins.
Well, we don’t have that pulled in, do we? :) I’m fine to do so if there’s one
that fits. On that note, I’ve been working on something else, related to query
parameters and cache keys and what not. As such, I realize we have a
substantial amount of duplications in this area, so my branch currently has the
following additions to tsutils/:
include/tsutil/Escape.h
include/tsutil/QueryParams.h
include/tsutil/StringConvert.h
tsutil: add ts::QueryParams and shared URL unescape
Add two dependency-free primitives in the ts namespace so the core and
plugins share one implementation of query parsing and URL decoding:
* ts::QueryParams - zero-copy query-string parse (over swoc::TextView),
keep/remove/filter, stable sort, form-urlencoded decode, and serialize.
* ts::unescape_form - application/x-www-form-urlencoded decode ('+' to
space, %XX to byte, malformed escapes left literal).
* ts::ts::hex_value is added to StringConvert
The real goal was ts::QueryParams, but that unraveled some lack in “escaping”
and encoding.
Brian: Instead of adding this to ts.h / InkAPI, maybe we should coordinate this
into include/tsutil, allowing for proper C++ APIs? I don’t see a ton of
usefulness to add completely new APIs using the old C style. I’m also wondering
if my ts:unescape_form is the same as your TSStringHtmlUnescape() ?
Cheers,
— Leif
>
> -- Masakazu
>
> On Mon, Jul 20, 2026 at 10:51 AM Brian Neradt <[email protected]>
> wrote:
>
>> [email protected]:
>>
>> Per issue:
>> https://github.com/apache/trafficserver/issues/13331
>>
>> I'm proposing adding an API to perform HTML escaping:
>>
>> constexpr bool USE_ATTRIBUTE_MODE = true;
>>
>> TSReturnCode TSStringHtmlEscape(const char * str, int str_len, char * dst,
>> size_t dst_size, size_t * length, bool use_attribute_mode);
>>
>> TSReturnCode TSStringHtmlUnescape(const char * str, int str_len, char *
>> dst, size_t dst_size, size_t * length);
>>
>> This is pretty analogous to our current TSStringPercentEncode/
>> TSStringPercentDecode API. See the draft PR implementing this here:
>> https://github.com/apache/trafficserver/pull/13408
>>
>> Please let me know if you have any thoughts or concerns.
>>
>> Thanks,
>> Brian Neradt
>> --
>> "Come to Me, all who are weary and heavy-laden, and I will
>> give you rest. Take My yoke upon you and learn from Me, for
>> I am gentle and humble in heart, and you will find rest for
>> your souls. For My yoke is easy and My burden is light."
>>
>> ~ Matthew 11:28-30
>>