Problem/Motivation
Url::toUriString()
doesn't work properly for user input. User input is expected to contain a leading slash. The toUriString()
method does not render it out.
This issue is a blocker for
#2426399: FieldPluginBase::renderAsLink() loses language prefix for tokenized paths β
(see
comment #47 β
on that issue).
Proposed resolution
1. Check user-entered strings for leading slashes in core/lib/Drupal/Core/Url.php.
2. Update necessary tests.
Remaining tasks
3. Review
4. RTBC
5. Commit
6. Update status of
#2426399: FieldPluginBase::renderAsLink() loses language prefix for tokenized paths β
to Active and comment there about next steps for that issue.
Steps to reproduce and test
1. To reproduce, download the "test-only" patch in comment #2, apply the patch, and run the test. (It should fail.)
For example:
wget https://www.drupal.org/files/issues/2657932-test-only.patch
git apply 2657932-test-only.patch
php ./core/scripts/run-tests.sh --sqlite /tmp/test.sqlite --verbose --non-html --file core/tests/Drupal/Tests/Core/UrlTest.php
2. Un-apply the patch (because the final patch will conflict with it).
For example:
git apply -R 2657932-31.patch
3. Download and apply the latest patch.
For example (using the patch in #31):
wget https://www.drupal.org/files/issues/2022-05-10/2657932-31.patch
git apply 2657932-31.patch
4. Run the tests locally again and it should pass this time.
For example:
php ./core/scripts/run-tests.sh --sqlite /tmp/test.sqlite --verbose --non-html --file core/tests/Drupal/Tests/Core/UrlTest.php
User interface changes
None.
API changes
None.
Data model changes
None.