Route with space at the end does not work

Created on 27 November 2017, almost 7 years ago
Updated 21 March 2023, over 1 year ago

Problem/Motivation

I have this issue, can you said if is a bug?

Steps to reproduce

1. Go to /admin/structure/block
2. Place any block, on Visibility/Page do it this:

3. Go to home (/) and you will see the block
4. Go to edit that block and add a extra space after <front>, like this:

5. The block will not show!

Proposed resolution

TBA

Remaining tasks

TBA

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Needs work

Version

10.0 โœจ

Component
Blockย  โ†’

Last updated about 20 hours ago

Created by

๐Ÿ‡บ๐Ÿ‡พUruguay rpayanm

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia anup.sinha Bengaluru

    Hi @smustgrave,

    Can we now merge this patch into Drupal 10 branch if everything looks good to you.

    Thanks & Regards,
    Anup

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    I cannot review it as I helped work on it.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    Verified the patch #28 and tested it on Drupal version 10.1.x. The patch works fine and I have added the before and after screenshots for reference.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Thanks, reviewed the patch at #28

    For posterity \h in regex matches any horizontal space character

    I wonder if this means something with a space in the middle of a path will no longer match?

    Can we add an extra test case with /example/with%20a%20space (i.e. url encoded space) to ensure it still matches.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Added additional test and it didn't cause a failure.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10
    +++ b/core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php
    @@ -150,6 +150,16 @@ public function getMatchPathData() {
    +        '/example/1 ',
    +        [
    +          '/example/1' => TRUE,
    +          '/example/2' => FALSE,
    +          '/example/with%20a%20space' => FALSE,
    

    Ah sorry, can we add a separate case where the URI matches the space

    I.e we want it to be TRUE

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave
          [
            // Test spaces.
            '/example/with a space',
            [
              '/example/with%20a%20space' => TRUE,
            ],
          ],
    

    Seems this fails so maybe the solution needs work.

  • Kaushik1216 โ†’ made their first commit to this issueโ€™s fork.

  • @kaushik1216 opened merge request.
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    @Kaushik1216 can you explain how your MR is different to the existing patch?

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil paulocs Belo Horizonte

    Here is change and the test suggested on #36. I attached the interdiff as well.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    CI failure

    And the MR 3610 from what I can is the same fix but with the test file removed.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ทBrazil paulocs Belo Horizonte

    Sorry. New patch and interdiff.

  • @larowlan MR 3610 will remove space at start and end and previous patch remove all spaces in page url .

  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Reviewing patch #43 and seems the point brought up by @larowlan in 36 has been addressed.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    The fail looks to be introduced here

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    There is confusion here about what is to be committed, the MR or the patch. Comment #45 refers to the patch but there is nothing in the issue summary to help the reviewer or committer to know what to look at. I have added the standard template to the Issue Summary and I am tagging this for an IS update.

    @Kaushik1216, Welcome to Drupal! Thanks for the interest in this issue. if an issue is using a patch workflow then it is usually best to continue with that. Introducing an MR can cause confusion, as in this case. and sometimes duplication of work.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium borisson_ Mechelen, ๐Ÿ‡ง๐Ÿ‡ช

    I disagree with the approach taken in the latest patches and would like us to still investigate what @catch wrote in #10.

    There is a reason in #11 about why this is difficult, but I think that we should still go trough that direction. Anything that is changed in the path matcher has performance implications for every single request, and while regexes are very fast, if we can avoid changing them that would be better for performance I think.

    Something like implode('\n', array_map(explode('\n', $input), function ($str) { return trim($str); })) (not actually tested, so not sure), should be enough in the form submit?
    It would mean the tests added here should be removed as well and replace with a test that tries to submit the form and checks that the saved configuration is different (without the spaces).

    That way, there is no code in the every single page request but only in the saving of the form.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Means we would have to tweak the test suggestion by larowlan in 33. As trim() doesnโ€™t pass that

Production build 0.71.5 2024