Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If I use a redirect in action with non-Latin characters, then get the error: "Input evaluation generated an invalid URI".
For example, I want to go to the outside at: http://othersite.com?rel=нелатинскиебуквы
Can somehow solve this problem?
Comment | File | Size | Author |
---|---|---|---|
#18 | 1726858-18-test-plus-fix.patch | 3.11 KB | TR |
| |||
#18 | 1726858-18-test-only.patch | 1.96 KB | TR |
Comments
Comment #1
ibraaheem CreditAttribution: ibraaheem commentedread about url encoding and use the corresponding letters/symbols.
Comment #2
TR CreditAttribution: TR commentedI can confirm that
http://example.com/?rel=нелатинскиебуквы
results in an "Input evaluation generated an invalid URI" error when used in a redirect URL. This should NOT happen.I can also confirm that using the URL-encoded version
http://example.com/?rel=%D0%BD%D0%B5%D0%BB%D0%B0%D1%82%D0%B8%D0%BD%D1%81%D0%BA%D0%B8%D0%B5%D0%B1%D1%83%D0%BA%D0%B2%D1%8B
works properly. But we should not have to do that!Changing this to a bug report for the current version of Rules. "Minor" because there is a simple work-around.
Comment #3
TR CreditAttribution: TR commentedThis only happens if the URL is absolute/external. A relative URL of
?rel=нелатинскиебуквы
works just fine.The cause of this bug is the core Drupal function valid_url(), which Rules uses to check the validity of the entered redirect URL. The valid_url() function is well-known to do the wrong thing in many cases. Dealing with Cyrillic is one of those known cases that valid_url() can't handle well.
So I think the solution here is to rawurlencode() the URL before checking it with valid_url(). That seems to work.
Attached are two patches:
Comment #5
TR CreditAttribution: TR commentedHmm, that was not as expected. It works properly when I test it on my local machine. I suspect there's something special about using absolute URLs in the testbot. Investigating ...
Comment #6
TR CreditAttribution: TR commentedRe-rolled against current HEAD.
Comment #8
TR CreditAttribution: TR commentedSame error as last year with the same patch, but it still works on my local dev environment (which is different than it was last year). DrupalCI doesn't provide any meaningful artifacts for D7 tests. So here's a new version of patch #6 with a few debugging statements added - hopefully that will shed some light on what is happening in the testbot.
Comment #9
TR CreditAttribution: TR commentedComment #11
TR CreditAttribution: TR commentedOne more print statement.
It seems that on the testbot, clean URLs are not enabled. And what is happening is that DrupalWebTestCase::getUrl() is returning a differently formatted string that the built-in Drupal function url() for this test case. Reading the documentation, I suspect that getUrl() is wrong here, but this print statement should let me determine that for sure. Then I can work-around the core bug.
Comment #13
TR CreditAttribution: TR commentedComment #15
TR CreditAttribution: TR commentedComment #16
TR CreditAttribution: TR commentedRemind me to stop hand-editing patches ...
Comment #18
TR CreditAttribution: TR commentedComment #19
TR CreditAttribution: TR commented