Rewrite as URL adding equals sign to end of url.

Created on 2 March 2012, over 13 years ago
Updated 16 July 2024, 12 months ago

Problem/Motivation

Currently drupal_get_query_array does't support a syntax like that 'http://domain.org?flag' because it sets the value
of flag to "". If drupal_http_build_query is called on this it is converted to 'http://domain.org?flag=' which is wrong.

Proposed resolution

Let drupal_get_query_array return what's expected.

Remaining tasks

Write tests, write a patch.

Original report by [robit8deb]

// Text of original report here.
(for legacy issues whose initial post was not the issue summary)
I have a scenario where a customer is using an external website in correlation with his drupal site. The external vendor is using poorly formatted urls that are getting (correctly) rewritten with and = sign at the end because it is expecting a value. For example, http:///foo.cgi?foo gets rewritten to http:///foo.cgi?foo=. I need to turn off this validation because the resulting url with the = sign at the end takes the user to page cannot be displayed.

I fixed this behavior on link cck fields using this patch:

http://drupal.org/node/1306352

However, the field that i am rewriting now is a Boolean field where, when on, gets rewritten to a link.

Please advise.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Base 

Last updated about 8 hours ago

Created by

🇺🇸United States robit8deb

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • 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

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇺🇸United States dysproseum

    Patch #64 updated to apply on Drupal 10.2.4.

  • 🇮🇹Italy kimlop

    I tested the last two patches (#71 #64) with core 10.3.5 and both don't work.

  • 🇫🇷France duaelfr Montpellier, France

    Patch #64 applies on Drupal 10.3.x and fixes the issue.
    I updated the IS and I believe that comments from #60 and #61 don't apply anymore with the approach followed in the patch.

    For novices: please convert #64 patch to a MR to ease maintainers job.

  • 🇺🇸United States smustgrave

    Fixes should be in MRs

    Have not reviewed yet.

  • 🇮🇳India sayan_k_dutta

    Working on it.

  • Pipeline finished with Failed
    8 months ago
    Total: 663s
    #328709
  • 🇮🇳India sayan_k_dutta

    Created MR for patch #64. Please review it.

  • 🇫🇷France duaelfr Montpellier, France
  • 🇺🇾Uruguay rsbarbano

    Patch #64 is working for me in a Drupal version 11.0.4.
    Thank you!.

  • 🇺🇸United States smustgrave

    Have re-ran tests twice and they still fail.

  • Pipeline finished with Success
    7 months ago
    Total: 499s
    #362943
  • Status changed to Needs review 7 months ago
  • 🇮🇳India sayan_k_dutta

    Tests are now passing, moving to Needs Review.

  • 🇧🇷Brazil igorgoncalves

    Hi Sayan, thanks for the effort.
    Despite the fact that tests have "Pass" status, there's one warning left, and checking the detail says:

    Drupal\Tests\Core\Utility\UnroutedUrlAssemblerTest::testAssembleWithExternalUrl with data set #7
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'https://example.com/test?foo'
    +'https://example.com/test?foo='

    which sounds like pretty much what we are testing here, isnt?

  • 🇮🇳India sayan_k_dutta

    @igorgoncalves yes, indeed the two strings of urls are different, that is what we need here. Do I need to make changes to test files, to remove the warnings. I don't have much knowledge of phpunit tests, but can look into it.

  • 🇮🇳India sayan_k_dutta

    All tests are now passing, warnings are resolved. Please review.

  • 🇮🇳India koustav_mondal Kolkata

    Checked in my local setup before and after changes. Attaching screenshots. LGTM+

  • Status changed to Needs work 4 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    The fix has issues - added a comment to MR.

  • First commit to issue fork.
  • 🇺🇸United States joegraduate Arizona, USA

    Updated the MR with @alexpott's recommended changes and also replaced strpos() with preg_match() using a regex that should prevent the false positives due to substring overlap that @alexpott noted by ensuring that the matches are either at the beginning of the query string or after a &.

  • Pipeline finished with Success
    about 2 months ago
    Total: 622s
    #486849
  • Pipeline finished with Success
    30 days ago
    Total: 649s
    #509567
  • 🇺🇸United States smustgrave

    Rebased as this MR was 800 commits back

    Feedback appears to be addressed on this one.

  • 🇺🇸United States xjm

    NR for a small commment improvement suggestion I made on the MR. It's okay to re-RTBC the issue if the suggestion is accepted (no need for an extra review cycle over something small).

  • First commit to issue fork.
  • Pipeline finished with Success
    2 days ago
    Total: 479s
    #531725
  • Pipeline finished with Failed
    2 days ago
    #532475
  • Pipeline finished with Success
    1 day ago
    #532477
Production build 0.71.5 2024