php-i18n Digest 21 Mar 2009 22:35:48 -0000 Issue 422

Topics (messages 1313 through 1316):

mb_check_encoding
        1313 by: Giacomo Mazzocato
        1314 by: Giacomo Mazzocato
        1315 by: Giacomo Mazzocato

problem with utf8_encode
        1316 by: Valkum

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Hi,
I'm having some problems with mb_check_encoding.
When it's invoked without parameters does it check
all the REQUEST variables to see if their values have the same
encoding
as mb_internal_encoding() ? (This is what I understood from the
manual)
As far as I know that doesn't happen.
Here's an example file :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
     <html>
       <head>
         <title>Help needed</title>
         <meta http-equiv="Content-Type" content=
                 "text/html; charset=utf-8" />
       </head>
       <body>
        <form action="?" method="post">
        <input type="text" name="foo" value="" />
        <input type="submit"  value="submit" />
        </form>
        <?php
mb_internal_encoding("UTF-8");
var_dump($_REQUEST) ;
echo "<p>" ;
if (mb_check_encoding()) {
   echo "request encoding ok" ;
} else {
   echo "request encoding not ok" ;
}
echo "</p>" ;
?>

       </body>
     </html>

If you post the value from your browser, all is ok because the
encoding of the page is recognized by the browser as utf-8 (I think).
But if I call that page with curl simulating an Invalid encoding
attack,
I get the same result(request encoding ok) while I should get request encoding 
not ok.
Here's the command I used :
curl  --data-urlencode  $'foo=prov\xef'  
http://localhost/mine/test/encoding.php
Thank you in advance
Bye,
Giacomo

--- End Message ---
--- Begin Message ---
Hi,
I'm having some problems with mb_check_encoding.
When it's invoked without parameters does it check
all the REQUEST variables to see if their values have the same
encoding
as mb_internal_encoding() ? (This is what I understood from the
manual)
As far as I know that doesn't happen.
Here's an example file :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
     <html>
       <head>
         <title>Help needed</title>
         <meta http-equiv="Content-Type" content=
                 "text/html; charset=utf-8" />
       </head>
       <body>
        <form action="?" method="post">
        <input type="text" name="foo" value="" />
        <input type="submit"  value="submit" />
        </form>
        <?php
mb_internal_encoding("UTF-8");
var_dump($_REQUEST) ;
echo "<p>" ;
if (mb_check_encoding()) {
   echo "request encoding ok" ;
} else {
   echo "request encoding not ok" ;
}
echo "</p>" ;
?>

       </body>
     </html>

If you post the value from your browser, all is ok because the
encoding of the page is recognized by the browser as utf-8 (I think).
But if I call that page with curl simulating an Invalid encoding
attack,
I get the same result(request encoding ok).
Here's the command I used :
curl  --data-urlencode  $'foo=prov\xef' 
http://localhost/mine/test/encoding.php
Thank you in advance
Bye,
Giacomo

--- End Message ---
--- Begin Message ---
Hi,
I'm having some problems with mb_check_encoding.
When it's invoked without parameters does it check
all the REQUEST variables to see if their values have the same
encoding
as mb_internal_encoding() ? (This is what I understood from the
manual)
As far as I know that doesn't happen.
Here's an example file :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
     <html>
       <head>
         <title>Help needed</title>
         <meta http-equiv="Content-Type" content=
                 "text/html; charset=utf-8" />
       </head>
       <body>
        <form action="?" method="post">
        <input type="text" name="foo" value="" />
        <input type="submit"  value="submit" />
        </form>
        <?php
mb_internal_encoding("UTF-8");
var_dump($_REQUEST) ;
echo "<p>" ;
if (mb_check_encoding()) {
   echo "request encoding ok" ;
} else {
   echo "request encoding not ok" ;
}
echo "</p>" ;
?>

       </body>
     </html>

If you post the value from your browser, all is ok because the
encoding of the page is recognized by the browser as utf-8 (I think).
But if I call that page with curl simulating an Invalid encoding
attack,
I get the same result(request encoding ok) but I should get request encoding not ok
Here's the command I used :
curl --data-urlencode $'foo=prov\xef' http://localhost/mine/test/encoding.php
Thank you in advance
Bye,
Giacomo
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

--- End Message ---
--- Begin Message ---
Hello,

i have a big problem.

When i try to encode a big string to utf8 i got a core dump

her is my code.


   <?php
   function is_utf8($string) {
      // From http://w3.org/International/questions/qa-forms-utf-8.html
      return preg_match('%^(?:
            [\x09\x0A\x0D\x20-\x7E]            # ASCII
          | [\xC2-\xDF][\x80-\xBF]            # non-overlong 2-byte
          |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
          | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
          |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
          |  \xF0[\x90-\xBF][\x80-\xBF]{2}    # planes 1-3
          | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
          |  \xF4[\x80-\x8F][\x80-\xBF]{2}    # plane 16
      )*$%xs', $string);
   }

   function output($string)
   {
       if(!is_utf8($string))
         $string = utf8_encode($string);
       return addslashes($string);
   }

   $string = <<<EOH
   <div align="justify">
   <p>- Im Aufbau -</p>
   <h3 id="aventurien">Aventurien</h3>
   <div style="border: 1px none ; margin: 5px 5px 5px 10px; float:
   right; width: 100px;"><strong>Navigation</strong> <br />
   <br />
   <a href="#aventurien">Aventurien</a><br />
   <a href="#ferdok">Die Stadt Ferdok</a><br />
   <a href="#weitere">Weitere Ziele</a></div>
   <p>{mosimage} Aventurien ist ein Kontinent der Welt Dere und
   Ausgangspunkt f&uuml;r die meisten Abenteuer in der Welt von <em>Das
   Schwarze Auge</em>. Von Nord nach S&uuml;d erstreckt sich der
   Kontinent ca. &uuml;ber 3000 Meilen, von Ost nach West sind es
   immerhin noch 2000 Meilen. Von den Tundren Thorwals bis zur
   W&uuml;ste Khom kann man so ziemlich alle Klimazonen in Aventurien
   finden.</p>
   <p>Im Herzen Aventuriens liegt das Kaiserreich, auch das Mittelreich
   genannt, mit seiner Hauptstadt Gareth (rot umrandeter Bereich).  Die
   Kultur erinnert entfernt an das mittelalterliche Europa. Die
   Handlung Drakensangs wird zu gro&szlig;en Teilen im Mittelreich
   spielen, genauer gesagt, in der Umgebung der Stadt Ferdok (s.u.).
   Doch auch andere, exotischere Orte sollen Ziel der Reise werden.</p>
   <p>Zahlreiche V&ouml;lker und Rassen bewohnen den Kontinent, allen
   voran nat&uuml;rlich die Menschenv&ouml;lker, die die Mehrheit der
   Bewohner stellen. Unter den Menschen gibt es zahlreiche
   unterschiedliche Kulturen, z. B. die wikinger&auml;hnlichen
   Thorwaler, das Nomadenvolk der Nivesen oder eben die
   Mittell&auml;nder. Daneben gibt es nat&uuml;rlich noch
   fantastischere V&ouml;lker wie die Elfen (mit mehrern Untergruppen),
   Zwerge, Orks und mehr, eben alles, was eine Fantasywelt zu bieten
   hat.</p>
   <p>&nbsp;</p>
   <h3 id="ferdok">Ferdok</h3>
   <p><a target="_blank" href="images/stories/stadtplan_g.jpg">
   {mosimage}</a></p>
   <p>Ferdok ist eine Grafenstadt im Mittelreich, etwas westlich der
   Hauptstadt Gareth, und hat etwa 3000 Einwohner. Sie geh&ouml;rt zu
   den &auml;ltesten menschlichen Siedlungen des Kosch. Im Laufe der
   Geschichte mu&szlig;te die Stadt jedoch wegen einer &Auml;nderung
   des Flu&szlig;laufes des Gro&szlig;en Flu&szlig;es im Jahre 270 BF
   verlegt werden, da die Stadt in der Bedeutungslosigkeit zu versinken
   drohte. Heute liegt Ferdok wieder direkt an der Einm&uuml;ndung des
   Rakula in den Gro&szlig;en Flu&szlig;. Obwohl  die Stadt die
   fr&uuml;here Bedeutung l&auml;ngst verloren hat, hat sich Ferdok als
   ein wichtiger Handelshafen etabliert (weltber&uuml;hmt: Ferdoker
   Bier). Hier werden die Waren von Gareth umgeschlagen, die &uuml;ber
   die gro&szlig;e Handelsstra&szlig;e von und nach Ferdok verfrachtet
   werden. Ferdok ist damit eines der Tore zum Westen und
   erm&ouml;glicht schnelle Reisen in andere Teile der Aventuriens.</p>
   <p>Verwaltungstechnisch geh&ouml;rt Ferdok zum F&uuml;rstentum
   Kosch, dessen Hauptstadt sie langezeit war. Mittlerweile hat sie
   diesen Status jedoch an Angbar verloren. Trotz seiner wichtigen
   Rolle als Handelsort sind die Bewohner Ferdoks ein eher biederes
   V&ouml;lkchen und h&auml;ngen der Erinnerung an die ruhmreichere
   Vergangenheit hinterher. Nachts muss man auf den Stra&szlig;en
   neuerdings aufpassen. Zur Handlungszeit verunsichert n&auml;mlich
   eine grauenhafte Mordserie die Bewohner Ferdoks und l&auml;sst die
   Bev&ouml;lkerung nachts nicht richtig schlafen. Einige Bereiche
   sollte man dann grunds&auml;tzlich nicht mehr besuchen, wenn einem
   die eigene Gesundheit am Herzen liegt.</p>
   <p>Die Stadt wird eine zentrale Anlaufstelle in Drakensang sein,
   weswegen sie auch vollst&auml;ndig, nach den Vorgaben des
   DSA-Regelwerks in das Spiel eingebaut wird. Der Stadtplan (zum
   Vergr&ouml;&szlig;ern anklicken) wurde von Radon Labs dem Regelwerk
   direkt entnommen und wird Euch auch f&uuml;r Drakensang gute Dienste
   leisten.</p>
   <br />
   <h3 id="weitere">Weitere Reiseziele des Spiels</h3>
   <a target="_blank"
   href="images/stories/artikel/map.jpg">{mosimage}</a> Insgesamt soll
   es 12 Hauptregionen geben, die jeweils ca. 1 Quadratkilometer
   gro&szlig; sind. Alle diese Regionen unterteilen sich nochmal in
   &uuml;ber 50 kleinere Gebiete. Bekannt sind neben Ferdok bislang:
   <ul>
       <li>Avestreu (kleines Dorf s&uuml;d&ouml;stl. von Ferdok)</li>
       <li>Dunkelwald (s&uuml;dl. von Ferdok)</li>
       <li>Ruine Blutberge (s&uuml;dl. von Ferdok, am Rand des
   Dunkelwaldes)</li>
       <li>Moorbr&uuml;ck (s&uuml;dl. des Dunkelwaldes)</li>
       <li>Burg Grimmzahn (westl. von Moorbr&uuml;ck)</li>
       <li>Murolosch (eine Zwergenstadt)</li>
       <li>der Berg Drachensang / Drakensang (im Amboss-Gebirge
   gelegen)</li>
   </ul>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>Ausf&uuml;hrlichere Infos:</p>
   <p><a title="Wiki Aventurica" target="_blank"
   href="http://dsa4.de/wiki";>Wiki Aventurica </a>(externer Link)<br />
   <a href="http://www.eychgras.de/koschwiki/index.php";
   target="_blank">KoschWiki</a> (externer Link)</p>
   <p>&nbsp;</p>
   </div>
   EOH;
   print_r(output($string));
   ?>

Please help me. When i delete some code from <ul> to </div> at the end, i get no core dump. only with the full text.

What is the problem??

Greetz Valkum

--- End Message ---

Reply via email to