We found a bug in the _init function that prevent redirection from older ISO or UTF8 url's. We tried to redirect an old static ISO HTML page to a new Drupal system. We found out this bug is caused by a default Firefox (2.0 tested only) internal setting named "network.standard-url.encode-utf8" with the value "false". This causes an URL like "http://example.com/laender/Schweden_Westkueste_Schwedens_Östergoetlands_Laen.html" to fail, while it encodes in Firefox with "http://example.com/laender/Schweden_Westkueste_Schwedens_%D6stergoetland..." and in IE with "http://example.com/laender/Schweden_Westkueste_Schwedens_%C3%96stergoetl...". As you can see the second one is correct for UTF8 based Drupal and the Firefox version is wrong. We played around with Apache config and all we tried failed and we finaly think this is a Client Problem we cannot solve with an encoding setting in the server, while the client does it own stuff. If i'm wrong about this i will be very thankful if someone provide a solution for this.
As a workaround we implemented the following solution that works well. Additional i found a bug on a code review db_escape_string(). The placeholder '%s' does this db_escape_string() automatically for you! I changed the code style a little bit (switched double and single quotes). See the following approach to solve the issue for older ISO and UTF8 URLs. So what we are trying to archive here is simple - we search for both encoded strings and get one result for the redirect to our new Drupal URL :-).
$path1 = $_GET['q'];
$path2 = utf8_encode($_GET['q']);
$r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $path1, $path2));
I think we can do this in a "one liner" like this:
$r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $_GET['q'], utf8_encode($_GET['q']));
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | path_redirect_utf8_urls2.patch | 1.11 KB | hass |
| #5 | path_redirect_utf8_urls.patch | 1.1 KB | hass |
Comments
Comment #1
hass commentedComment #2
hass commentedFound something on the net about this and Firefox 2.0 is the source of this problem. Firefox 3.0 will change back to URL encoding with UTF8 what the RFC says... see http://www.nabble.com/Firefox-URL-encoding-t2164524.html
Comment #3
hass commentedComment #4
jjeff commentedI'm having trouble understanding your changes exactly. Can you please post a patch? It all sounds like good stuff, but I'm having trouble sorting through all of the bits and pieces.
Thanks!
Comment #5
hass commentedHere is the patch.
Comment #6
hass commentedMaybe better to use EALL save code for future... patch attached.
D6 requires this, too.
Comment #7
HorsePunchKid commentedBy the way, the quote-swapping in the queries will help with Postgres support. The SQL standard is to surround strings in queries with single quotes, which means it's easier to surround your queries in PHP with double quotes.
Comment #8
jjeff commentedCommitted. Please download 5.x-1.1-beta1 to test.
Comment #9
(not verified) commented