Skip to content

Escape data in the HTML outputs; draw tokens from random_int - #11

Merged
daedeloth merged 2 commits into
masterfrom
fix/output-escaping-and-tokens
Oct 7, 2026
Merged

daedeloth merged 2 commits into
masterfrom
fix/output-escaping-and-tokens

Conversation

@daedeloth

Copy link
Copy Markdown
Member

What changes

HTML data outputs. Outputs\Table, Outputs\PrintR and the data fallback of Outputs\HTML show a data structure in an HTML page. Keys and values are data, so they are now escaped (htmlspecialchars, ENT_QUOTES | ENT_SUBSTITUTE, UTF-8). The table's own markup is unchanged.

Also fixed on the way:

  • Table sent Content-type: text/html, charset=utf-8 (comma); it is now text/html; charset=utf-8.
  • PrintR concatenated the return value of print_r() without the return flag, so it printed the data outside the <pre> and then a 1; it now prints the escaped dump inside a closed <pre>.

Tokens. TokenGenerator::getToken() and getSimplifiedToken() draw from random_int() instead of mt_rand(). Same alphabets, same lengths, same signatures.

Behaviour change

A value that contained HTML on purpose and was shown through Table, PrintR or the data fallback of HTML now appears as text. A response body set with setBody() is left alone.

Tests

New tests/OutputEscapingTest.php. With phpunit --exclude-group=database (the CI selection) on PHP 8.5 locally: 208 tests, 3 errors, all in MySQLErrorTest, which needs the mysqli extension my local PHP lacks and errors the same way on master.

Release

Intended for 3.3.1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DqZUi2UiBJP6rZoCSRcdpE

daedeloth and others added 2 commits October 7, 2026 09:05
The Table, PrintR and HTML outputs show data as text: keys and values
are escaped. PrintR prints the data instead of print_r's return value.
TokenGenerator uses random_int; alphabets and lengths are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqZUi2UiBJP6rZoCSRcdpE
@daedeloth
daedeloth merged commit 35903d8 into master Oct 7, 2026
5 checks passed
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