1

problem loading image in Internet Explorer (10) while at chrome & firefox it's ok when the username parameter is in hebrew (rtl language) the problem occurs for css and html:

background: 0 url('php/ajax/ajax-user-image-read.php?username=רועי') no-repeat';

img src="php/ajax/ajax-user-image-read.php?username=רועי" alt=""

both works ok for english

background: 0 url('php/ajax/ajax-user-image-read.php?username=roee') no-repeat';

img src="php/ajax/ajax-user-image-read.php?username=roee" alt=""

when hebrew I receive the username parameter as ???? at the server side.

my html page has meta charset="UTF-8" and all other hebrew works ok.

I don't think the php code will help here because it receives question marks and not valid data but here it is:

<?php

session_start();

require_once '../gw-database.php';
require_once '../gw-functions/gw-functions-user.php';

if (isset($_SESSION['username'])) {
    if (isset($_GET['username'])) {
        if (!empty($_GET['username'])) {

            $username = ('current' === $_GET['username']) ? $_SESSION['username'] : $_GET['username'] ;

            $image = userImageGet($username);
            if (false !== $image) {

                header('Content-Type: '.$image['type']);
                echo $image['image'];
            }
            else {
                logRunTimeMessage($_SESSION['username'], 'server', $error, 'In file '.strrchr(__FILE__, "\\").' at line '.__LINE__.' - Error fail to get user image', time());
            }
        }
    }
}
teach me
  • 453
  • 5
  • 20
  • 1
    Where are you receiving the username, using what code? Please show the relevant portions of the PHP code where you are using the user name – Pekka Jan 06 '14 at 19:03
  • You need to urlencode the Hebrew (the other browsers do that for you). Take a look at this list of [allowed](http://en.wikipedia.org/wiki/URL#List_of_allowed_URL_characters) URL characters. – Elliott Frisch Jan 06 '14 at 19:40
  • @ElliottFrisch I don't believe that is true, and I don't think that Wikipedia article is correct. I believe you can use UTF-8 characters as-is in the URL. – Brad Jan 06 '14 at 19:46
  • possible duplicate of [Why Internet Explorer doesn't url-encode the urls?](http://stackoverflow.com/questions/13492727/why-internet-explorer-doesnt-url-encode-the-urls) – Elliott Frisch Jan 06 '14 at 19:47
  • @Brad Do [you](http://stackoverflow.com/a/13492806/2970947)? You can use UTF-8 in the hostname, but that's not the same thing. – Elliott Frisch Jan 06 '14 at 19:48
  • Also [here](http://stackoverflow.com/questions/2742852/unicode-characters-in-urls). – Elliott Frisch Jan 06 '14 at 19:49

1 Answers1

0

Use URLENCODE

Example:

$username = 'רוע';
/*... some code ...*/
src="php/ajax/ajax-user-image-read.php?username=<?php echo urlencode($username);?>" alt=""
Root
  • 2,269
  • 5
  • 29
  • 58