Skip to content

4.3.3: the control UniqueID separator is configurable; the default stays '$' (back-port of #1623) - #1624

Open
belisoful wants to merge 3 commits into
pradosoft:prado-4.3from
belisoful:1612-id-separator-4.3
Open

belisoful wants to merge 3 commits into
pradosoft:prado-4.3from
belisoful:1612-id-separator-4.3

Conversation

@belisoful

@belisoful belisoful commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Back-port of #1623 for #1612 to 4.3.3. The separator between the IDs of a control UniqueID is configurable, and the default stays $, so nothing changes for an application that does not set it.

Changes

  • TControl::getIdSeparator() / setIdSeparator() are static, as in 4.4. DEFAULT_ID_SEPARATOR, the 4.4 name, equals ID_SEPARATOR ($) here. ID_SEPARATOR is not deprecated on 4.3.
  • Validation: a separator is one ASCII punctuation character other than _, . and [. Anything else throws TInvalidDataValueException (control_idseparator_invalid).
  • TPageService IdSeparator sets it from the configuration and is refused after init(). IdSeparator=":" is the 4.4 default and passes OWASP Core Rule Set rule 942290.
  • Callers read the accessor: TRadioButton::getUniqueGroupName(), TJuiEventParameter::getControl(), and TDatePicker, including the '$day', '$month' and '$year' literals in getDateFromPostData().

Client script

The check box, radio button and rating list scripts (controls.js, activecontrols3.js, ratings.js) built each item's EventTarget as ListName$cN. TCheckBoxList::getPostBackOptions() sends the separator as IdSeparator, and the five sites use it, with $ when the option is absent.

Hidden field id

As in 4.4, the id of a TClientScriptManager hidden field is its name. renderHiddenFieldsInt() rendered it as strtr($name, ':', '_'), and checkHiddenField() in ajax3.js replaced only the first :. Both were no-ops for a $ name. With IdSeparator=":" they would disagree on a name with two colons, and a hidden field registered under a UniqueID would render the control's ClientID as its id, duplicating the control's own element.

Behavior change in a point release: a hidden field name with a literal : keeps it in the id; it was _. No framework control registers such a name. HISTORY.md and the "Upgrading from v4.3.2" list say so.

Tests

testHiddenFieldNameSpecialCharacters() asserted the colon mapping and is testHiddenFieldIdIsItsName(). New tests cover the $ default, a set separator through getUniqueID(), getClientID(), convertUniqueIdToClientId() and findControl(), valid and invalid separators, the TPageService property, and the TDatePicker and TRadioButton names under $ and :. Existing tests and Playwright specs are unchanged.

php-cs-fixer, PHPStan, the full unit suite (PHP 8.2), ESLint and vitest pass. The active check box, radio button and rating list Playwright specs pass in Chromium with the default and with IdSeparator=":" set on the harness application for the run; with : and without the client script change, the list specs fail. The 37 active-controls specs pass in Chromium after the hidden field change. PHP 8.1, the other browsers and the rest of the Playwright suite were not run locally.

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