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']));

Comments

todd nienkerk’s picture

I'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.

todd nienkerk’s picture

Also 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.

hapydoyzer’s picture

Status: Active » Needs review
StatusFileSize
new491 bytes

Adding urldecode() work`s for 5.x-1.x-dev
Patch attached.

dave reid’s picture

Status: Needs review » Fixed

So, 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dicreat’s picture

Version: 6.x-1.x-dev » 5.x-1.1
Status: Closed (fixed) » Needs review

In 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.

dave reid’s picture

Version: 5.x-1.1 » 6.x-1.x-dev
Status: Needs review » Fixed

@dicreat Please try the 5.x-1.x-dev version of the module and report back if it works or not.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.