When setting a node's URL path to something like ÅÄÖåäö (Swedish characters in this case) the URL will (seemingly correctly) become:

http://localhost/lab/drupal51/?q=%C3%85%C3%84%C3%96%C3%A5%C3%A4%C3%B6

But when trying to browse the following url in my browser:

http://localhost/lab/drupal51/?q=ÅÄÖåäö

...it gets rewritten as

http://localhost/lab/drupal51/?q=%C5%C4%D6%E5%E4%F6

And thus the correct node is not found.

Drupal.org rewrites the URL in the same manner. Try http://drupal.org/ÅÄÖåäö
It will show:

http://drupal.org/%C5%C4%D6%E5%E4%F6

MediaWiki sites though, rewrites this correctly. Try http://www.mediawiki.org/wiki/ÅÄÖåäö
It will show:

http://www.mediawiki.org/wiki/%C3%85%C3%84%C3%96%C3%A5%C3%A4%C3%B6

Seems like a charset issue, where, on setting the path it is rewritten with UTF-8, but on requesting the URL it is rewritten with something like ISO-8859-1?

(I noticed also that this works correctly within the wiki if using the Liquid wiki module, http://drupal.org/project/Liquid if that can help in some way...)

This was tested on Drupal 5.1 (official release) and 5.2 dev as of 2007-02-09, running on:
Windows XP Professional
ApacheFriends XAMPP Lite version 1.5.4a
+ Apache 2.2.3
+ MySQL 5.0.24a
+ PHP 5.1.6 + PEAR (basic package)

CommentFileSizeAuthor
#5 path.inc_.patch1.79 KBsorenp

Comments

Steven’s picture

Status: Active » Closed (works as designed)

Drupal uses UTF-8 internally everywhere. If you enter a path in UTF-8 encoding (as should be the default behaviour), it should come out as UTF-8 escaped bytes in the path.

For example, using Drupal 5:

http://acko.net/Testing-%C3%9B%C3%B1ic%C3%B6d%C3%A9-%E2%80%B9%E2%82%ACha...
http://acko.net/Testing-Ûñicödé-‹€harachters›-∞

Clicking the bottom link works fine for me and pasting it into the address bar works as expected. Any browser that supports some form of internationalization should default to using UTF-8 for URLs. However, given that Drupal always outputs the former escaped variant and not the latter, there should be no problems.

saml’s picture

Your link works for me too, but
http://acko.net/ÅÄÖåäö
still gives
http://acko.net/%C5%C4%D6%E5%E4%F6
while it should give
http://acko.net/%C3%85%C3%84%C3%96%C3%A5%C3%A4%C3%B6

Which is the URL that Drupal sets, but it doesn't rewrite like that when requesting it.

Could you test creating a node with the name 'ÅÄÖåäö', and then trying to request it via http://acko.net/ÅÄÖåäö ?

sorenp told (in http://drupal.org/node/107732) that he has a patch for this, so I'm looking forward to test it.

Regards,
Samuel

saml’s picture

Status: Closed (works as designed) » Postponed (maintainer needs more info)

(Just opened the issue again, until it is confirmed that it is resolved/working correctly)

saml’s picture

Status: Postponed (maintainer needs more info) » Active

(Sorry for multipost... think this status is more appropriate)

sorenp’s picture

StatusFileSize
new1.79 KB

The problem is caused by some browsers requesting URI's in local encoding (ISO-8859-1 in my case) rather than UTF-8. Since Drupal does nothing to handle the encoding of $_GET['q'], things are messed up good.

(I noticed that Firefox 1.4 and 2.0 has this problem, while IE6 (surprisingly) does send URL's in UTF-8.)

I've made a small patch (attached) to path.inc that adds a check/conversion for non-UTF-8 sequences in $_GET['q'] before the rest of the code in drupal_init_path is executed. A limitation is that non-UTF-8 encoded strings are assumed to be in ISO-8859-1.

This will work on most installations. There might, however, be problems on some servers due to a bug in the Apache rewrite engine. So far, it has only appeared on my windows installation of Apache 1.3.34. My Linux servers are fine. The problem is that the rewrite engine screws up with UTF-8 strings and manages to alter them in a way that they are no longer legal UTF-8 sequences.

I've installed the following script on several servers (index.php):

<?php
print($_SERVER['REQUEST_URI']);
print "<br />";
print(urlencode($_GET['q']));

together with the Drupal .htaccess file.

On my windows machine the following requests and results are produced:

Request (UTF-8 in first character):
http://localhost/%C3%B6
Response:

/%C3%B6
%E3%B6

Request (UTF-8):
http://localhost/abc%C3%B6%C3%B6abc/def%C3%B6def
Response:

/abc%C3%B6%C3%B6abc/def%C3%B6def
abc%E3%B6%E3%B6abc%2Fdef%C3%B6def

Request (ISO-8859-1):
http://localhost/%F6
Response:

/%F6
%F6

As you see, the windows Apache server destroys the UTF-8 characters that appear in the part before the first slash (after rewrite base). This never causes a problem with Liquid since all ids are of the type wiki/*, but for general paths this might be a problem.

Hope this helps.

saml’s picture

Tested and seem to work correctly on:

1) My local server:
Drupal: 5.2 dev
MySQL database: 5.0.24a
PHP: 5.1.6
Unicode library: PHP Mbstring Extension
Web server: Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d mod_autoindex_color PHP/5.1.6

2) My shared host:
Drupal: 5.2 dev
MySQL database: 4.1.21
PHP: 5.1.5
Unicode library: PHP Mbstring Extension
Web server: Apache/1.3.37 (Unix) Sun-ONE-ASP/4.0.2 PHP/5.1.5 mod_throttle/3.1.2 FrontPage/5.0.2.2623 mod_psoft_traffic/0.1 mod_ssl/2.8.28 OpenSSL/0.9.6b

Requesting http://rilacademy.org/drupal52dev/Länk in my browser (Mozilla 1.5.0.9, Sv) still gives http://rilacademy.org/drupal52dev/L%E4nk though, while after editing the node I see http://rilacademy.org/drupal52dev/L%C3%A4nk , but both of the URLs works and give the correct node.
Thanks a lot!

sorenp’s picture

Requesting http://rilacademy.org/drupal52dev/Länk in my browser (Mozilla 1.5.0.9, Sv) still gives http://rilacademy.org/drupal52dev/L%E4nk though, while after editing the node I see http://rilacademy.org/drupal52dev/L%C3%A4nk

For some reason Mozilla/Firefox never displays URL's in local formating. The reason for the URL's being different is quite simple; When typing the character on your keyboard, Mozilla is given the character in local formating (ISO-8859-1) and converts it to %E4. When the link is returned by Drupal, it has been converted to UTF-8 (by my patch) and thus Mozilla converts it to %C3%A4 which is the UTF-8 code for the character.

If it's important to have one unique URL for each node, there is a possibility to place a redirect when the requested URL is in ISO-8859-1 (this is what Liquid does). I'm, however, not sure it's worth it.

// Soren

sorenp’s picture

Status: Active » Needs review
drumm’s picture

Version: 5.x-dev » 6.x-dev
Steven’s picture

Status: Needs review » Closed (won't fix)

I cannot reproduce this problem myself, and if it is indeed Apache doing it, then you need to file an Apache bug report, upgrade to a newer version or find the right setting.

Drupal can only work with what it is given, and we expect that to be UTF-8, as per the web standards that all the browsers implement. Apache should not alter such strings.