If you happen to have an URL with special characters (like spaces for example), the $path variable is not correct.
echo request_uri(); // Gives: /Style%20It!%20-%20Online/www.xxxxxxx.be/?q=nl
echo $GLOBALS['base_path']; // Gives: /Style It! - Online/www.xxxxxxx.be/
echo $path; // Gives: xx.be/?q=nl
Solution: urldecode() the request_uri() value. (Line 28)
$path = substr(urldecode(request_uri()), strlen($GLOBALS['base_path']));
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | path_redirect-5.x-1.x-dev-fix_special_characters.patch | 491 bytes | hapydoyzer |
Comments
Comment #1
todd nienkerk commentedI'm having the same problem on a 5.x site. URLs with commas
(/focus/placement,features)get encoded as(/focus/placement%2Cfeatures). This becomes a problem when I have to add a *second* redirect(/focus/placement%2Cfeatures)to handle the resulting 404, whose percent character gets doubly encoded as(/focus/placement%252Cfeatures)-- and on and on.Comment #2
todd nienkerk commentedAlso verified on a different 5.x site. If the user has accidentally added a node with curled quote marks in the title (“like_these”), redirects to or away from that nasty URL won't work. Encoding the chars (%E2%80%9Clike_these%E2%80%9D) doesn't work, either, for the same reason stated in my post above (the double-encoding of the percent sign).
The only fix, in this case, is to delete the nasty alias entirely and grit your teeth through all the 404s.
Comment #3
hapydoyzer commentedAdding urldecode() work`s for 5.x-1.x-dev
Patch attached.
Comment #4
dave reidSo, without even reading this issue, I added this myself so that UTF8 characters could be used in the URLs. Marking as fixed. Will backport to 5.x sometime soon.
Comment #6
dicreat commentedIn addition to patch #3 I've been replace in path_redirect.module at line 37:
$r = db_fetch_object(db_query("SELECT rid, redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $path, urlencode(utf8_encode($path))));with
$r = db_fetch_object(db_query("SELECT rid, redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $path, utf8_encode(urlencode($path))));Now all urls with special characters redirecting fine.
Comment #7
dave reid@dicreat Please try the 5.x-1.x-dev version of the module and report back if it works or not.