Problem/Motivation
ConfigTranslationCacheTest fails if
$field_label_fr = $this->randomString();
contains a ' character. This is because the test is using assertEscaped(). Field labels are no longer escaped in the admin interface, they are XSS::adminFilter()'ed. This was changed in #2409559: User should be able to identify required fields from field listing (unintentionally).
Steps to reproduce
Change the line to $field_label_fr = $this->randomString() . "'some quotes'"; - the test will always fails.
Proposed resolution
Use #plain_text instead of #value to escape these values like they used to be.
MR for fix: https://git.drupalcode.org/project/drupal/-/merge_requests/13911
MR for proof: https://git.drupalcode.org/project/drupal/-/merge_requests/13913
MR for fail: https://git.drupalcode.org/project/drupal/-/merge_requests/13914
Note this is different from $translatable_field_setting = $this->randomString(); - which uses escaping. That's because this appears on the translation form. The label is part of the admin listing page which uses XSS filtering.
Remaining tasks
User interface changes
None
Introduced terminology
N/a
API changes
None
Data model changes
None
Release notes snippet
N/a
Issue fork drupal-3559326
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
alexpottCreated 3 MRs. 1 for the real fix, 1 for a proof and 1 to show the fail.
Comment #6
alexpottThis was introduced by #2409559: User should be able to identify required fields from field listing which changed the label escaping strategy from escaping to admin filtering...
Comment #7
dwwThanks for this incredibly thorough bug report and fix! Let's smash it.
'in the label, and not fixing the assertions:'into the label.I see nothing else to improve here. In spite of my usual preference for verbosity and comments, I don't think we want a comment to explain why we're not using
assertEscaped(). We don't comment about all the wrong ways to do things we're not using. 😂 There's nothing confusing or intuitive aboutpageTextContains().Ship it!
Thanks again,
-Derek
Comment #8
alexpottComment #9
dwwMy RTBC in #7 was just before the "Change approach" commit and summary update. The new summary explains why this started happening recently. That's even better.
I did some slight edits for formatting, and to clarify that the test is not using
assertEscaped()"incorrectly". Also trying to get the title more accurate to the new approach.I'll wait to RTBC until the dust settles and the MR pipelines are as expected.
Comment #13
longwaveOops, crossposted while I was committing this! It looks good to me so let's get it in.
Committed and pushed 6c71422c72b to 11.x and cc4e5423465 to 11.3.x. Thanks!