Keep SteamID64 HTML pattern braces out of Smarty - #20
Conversation
Smarty treated {17} as a tag, so native HTML validation rejected a valid 17-digit SteamID64.
A {literal} wrap in the attribute paired with {literal} in a comment and made PHPStan miss edit-ban View properties.
ReviewRoot cause and fix are correct, and the coverage is unusually thorough for a one-character-class bug. What I verified locally on
No blocking objection. Notes below, roughly in descending order of value. 1. The PR description no longer matches the codeThe body says the fix is 2. The new E2E test escapes the file's serial guard
With 3.
|
Description
A valid 17-digit SteamID64 (for example
76561198179807307) was rejected by native HTML validation on Add a comm block, Add a ban, Submit a ban, and the matching edit forms. The browser popover told the operator to enter a 17-digit SteamID64 even though that is exactly what they typed.Steam2 (
STEAM_0:1:N) and Steam3 ([U:1:N]) still worked.Root cause is Smarty, not the PHP gate. Template source used:
pattern="STEAM_[01]:[01]:\d+|\[U:1:\d+\]|\d{17}"Smarty's
{/}delimiters treat{17}as a tag. The rendered HTML became\d17(quantifier dropped). The browser then rejected every 17-digit SteamID64. The Steam2 / Steam3 arms use\d+, so they never hit this.SteamID::HANDLER_STRICT_REGEXon the PHP side was already correct. Submitting via curl / a third-party theme that skips native validation would have succeeded. The existing E2E happy path usedSTEAM_0:1:14202020, so CI never caught it.Fix: wrap the Steam64 arm as
{literal}\d{17}{/literal}so Smarty leaves the braces alone. Rendered HTML is again\d{17}.Touched templates (every occurrence of this pattern):
web/themes/default/page_admin_comms_add.tpl(reported surface)web/themes/default/page_admin_bans_add.tplweb/themes/default/page_admin_edit_ban.tplweb/themes/default/page_admin_edit_comms.tplweb/themes/default/page_admin_edit_admins_details.tplweb/themes/default/page_submitban.tplNot affected: install wizard (Steam2-only pattern, no brace quantifier), PHP regexes, JS already inside
{literal}blocks.Motivation and Context
Operators who paste a Community ID into Add Block / Add Ban / Submit Ban hit a native validation popover and cannot submit, even though the value is valid and the server would accept it.
How Has This Been Tested?
SteamIDValidationOrderTest(12 tests, 81 assertions), including:{literal}\d{17}{/literal}testRenderedSteamPatternKeepsSeventeenDigitQuantifier: Smarty-compiles each extractedpatternand asserts the HTML ispattern="STEAM_[01]:[01]:\d+|\[U:1:\d+\]|\d{17}"testTemplatesHaveNoBareDigitBraceQuantifiers: scans allweb/themes/**/*.tpl, strips{literal}and{* *}, fails on leftover{<digits>}comms-add-steamid-validation.spec.tsnow fills76561198179807307on add-block, add-ban, and submit, and asserts the renderedpatternplusvalidity.valid\d{17}in a.tplpatterndoes not regressTypes of changes
Checklist: