Closed (duplicate)
Project:
Redirect
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Feb 2012 at 12:34 UTC
Updated:
20 May 2025 at 21:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
trante commented@digital006 hello,
i have such an error: http://drupal.org/node/1448706
and couldn't find a solution..
to reproduce can you please create a new node with non-ASCII characters and then change its alias
and check whether old alias goes to non-ASCII aliased node?
Comment #2
jaydub commentedThe issue here is that in fact a URL with spaces is not a 'valid' URL (to be valid it does need to be encoded). The add redirect form runs validation on the redirect field and tests the path with the function valid_url() which is what is causing the failure here. I'm not sure if this could cause undesirable side effects but one could perhaps add in a call to drupal_encode_path() before the valid_url() test is run.
attaching a patch which at least fixes the case above. The result is the redirect string being stored in the DB with the encoded space ('%20') which seems to be the desired result anyway.
Comment #3
jaydub commentedComment #4
James A commentedI'm also getting this issue with spaces in the path on version 7.x-1.0-rc1. Did you include the patch above in rc1 or is there a reason why it was left out?
Thanks for your help in advance.
Comment #5
TimG1 commentedHi All,
I tried this and it's not working the way I'd like it to. Yes, it converts spaces to %20 but I would like to save with the space, not encoded...exactly as typed.
Here's my use case. I have a list of faculty. I have a view showing all the faculty. There are different types of faculty. The URLs changed and I would like "example.com/adjunct-faculty" to redirect to "example.com/people/Adjunct Faculty". NOT "example.com/people/Adjunct%20Faculty". example.com/people is a view that will take the argument and using the "overwrite title" feature will overwrite the title of the page. Since there are no faculty tagged with "Adjunct%20Faculty" My view now shows "Adjunct%20Faculty" as the page title instead of "Adjunct Faculty" and the no results found message.
Thanks for reading,
-Tim
Comment #6
TimG1 commentedHi again,
Just learned that if I use "example.com/people/Adjunct-Faculty" that will get changed to "Adjunct Faculty" and works fine. So, just replace spaces with - and it works.
Thanks again,
-Tim
Comment #7
jwilson3Marked #1570350: Bugs when there is a space in filename as a duplicate.
Comment #8
jwilson3Lets clarify the issue title; these aren't aliases, but redirects.
Comment #9
wizonesolutionsThe patch indeed encodes URLs properly, but it doesn't fix the re-encoding issue when the redirect is actually passed to
url(). It kind of needs to be stored unencoded in the database. This might be another issue.In any case, here's a re-rolled version of this patch for now.
Comment #10
wizonesolutionsPrevious patch contained evil whitespace.
Comment #11
msharp.chi commentedI tried those patches, but the issue I have with them is that it introduces a double-encoding error i.e. save the url once and spaces are converted to %20. Save it twice and you get %2520 and so on.
The patch I've added separates the validation of the value from making sure it looks right. This ensures that the url is saved with spaces so it looks right, but validated with the appropriate encoding to make sure it validates correctly.
Comment #13
javiereduardo commentedpatch #11 works. Thanks! (drupal 7.22 - redirect 7.x-1.0-rc1+4-dev) (I patched editing directly the file)
Comment #14
javiereduardo commented#11: redirect-space-fix.patch queued for re-testing.
Comment #17
gumdal commentedI had the same issue. But it could be solved.
What I was trying to do is to add the following URL in the Source / From field:
http://www.indiansnakes.org/Snakedatabase/Kraits/common_krait/common%20krait.html
But instead I had to add the following URL:
http://www.indiansnakes.org/Snakedatabase/Kraits/common_krait/common krait.html
If you include the blank space in the source URL, Redirect module will automatically encode it with %20. If you replace the space and provide %20, Redirect module will encode it as %2520
Comment #18
Reuben Unruh commentedPatch from #11 with file paths from within the module instead of from from Drupal root.
Comment #19
Reuben Unruh commentedComment #20
leewillis77 commentedHi Reuben,
In your code shouldn't the check:
$testvalue != '<front>'be run against $value, not $testvalue?
Comment #21
pere orgaI agree
Comment #22
leewillis77 commentedThe revised patch contains the change I suggested.
Comment #23
pere orgaIs the issue related to #1238418: percent-encoded characters in URLs are double-encoded ? I guess so.
Comment #24
leewillis77 commentedLooks so - I've added a note and linked the issues.
Comment #25
summit commentedHi,
I implemented #22 patch. Am I ok for now?
greetings,
Martijn
Comment #26
tjmoyer commentedI'm not sure that patch is the right way to handle this. Drupal already encodes the URL when delivering the page or file, as evidenced by the fact that an encoded URL added to the redirect table in the database gets re-encoded when attempting to deliver it.
And we don't want to avoid a check for whether a file exists or not.
Instead, I purpose that we decode the URL that is submitted so redirect saves that, and the Drupal will encode it when it's needed. Here's my patch.
This seems to work for me. Does anyone see any potential issues with this?
Comment #27
tjmoyer commentedHere's a new patch that includes url decoding for the from field, as well.
Comment #28
summit commentedHi @tjmoyer, I implemented your patch and until now its ok.
greetings, Martijn
Comment #29
srclarkx commentedThis doesn't solve the problem of encoded characters in the query string. It only fixes the part before the '?' .
Comment #30
bennybobw commentedThe patch in #27 will break urls where there is no drupal_get_normal_path. E.g. if I have a views url set up as workshops/% and I want to redirect ed101 -> workshop/Education%20101, drupal_get_normal_path will return 'workshop/Education 101', which fails valid_url because you can't have an unencoded space in the url.
Comment #31
cafuego commentedYou can work around this problem by redirecting to an external URL, which causes Drupal to *not* double encode the special characters.
For example.com:
Comment #32
chris matthews commentedComment #33
bkosborneI observe this issue in Drupal 8 version of Redirect as well. I created a separate bug report for that.
Comment #34
wylbur commentedClosing this as Outdated as Drupal 7 is EOL.