Skip to content

http: decode URI-encoded HTMX request headers - #120

Merged
rameel merged 2 commits into
mainfrom
http/decode-auto-encoded-request-headers
Nov 2, 2026
Merged

rameel merged 2 commits into
mainfrom
http/decode-auto-encoded-request-headers

Conversation

@rameel

@rameel rameel commented Nov 2, 2026

Copy link
Copy Markdown
Owner

HTMX 1.9.x and 2.x URI-encode a header value that the browser cannot send as is, such as Cyrillic text,
and mark it with an additional *-URI-AutoEncoded header. HtmxRequestHeaders ignored the marker:

Property Input Before After
Prompt Answer Привет %D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82 Привет
Trigger id="форма" %D1%84%D0%BE%D1%80%D0%BC%D0%B0 форма
TriggerName name="имя" %D0%B8%D0%BC%D1%8F имя
Target hx-target="#цель" %D1%86%D0%B5%D0%BB%D1%8C цель

String properties now decode a value when its marker is true. A value without the marker is returned as sent,
because it may contain a literal %. The marker name is built only for a value that contains %,
so other values do not allocate.

HTMX 4.x does not mark encoded values, so Prompt, Target, and Source are still returned as sent.

HTMX 1.9.x and 2.x URI-encode a header value that the browser cannot
send as is and mark it with an additional *-URI-AutoEncoded header.
The string properties of HtmxRequestHeaders ignored the marker, so a
Cyrillic hx-prompt answer reached the application as %D0%9F%D1%80...

Decode the value when the marker is true. A value without the marker
is returned as sent, because it may contain a literal percent sign.
HTMX 4.x does not mark encoded values, so they are still returned as
sent.
@rameel
rameel merged commit 72c5653 into main Nov 2, 2026
1 check passed
@rameel
rameel deleted the http/decode-auto-encoded-request-headers branch November 2, 2026 17:25
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.

1 participant