æåã¨ã³ã³ã¼ãã£ã³ã°ã®å¦¥å½æ§ç¢ºèª(ããªãã¼ã·ã§ã³)ã«ã¤ãã¦
大å£ããããã³ã¡ã³ããããã ãã¾ããã®ã§ãæå¾ã«è¿½è¨ãã¾ãã(2009.09.22)ã
å°ãæéãçµã£ã¦ãã¾ãã¾ãããã以ä¸ã®ãã¼ã¸ãèªãã§ãPHP ã«é¢é£ããé¨åã«ã¤ãã¦æã£ããã¨ãæ¸ãããã¨æãã¾ãã
- http://blog.ohgaki.net/char_encoding_must_be_validated
- http://blog.ohgaki.net/is-char-encoding-problem-difficult
ç§ã®ç解ãééã£ã¦ããªããã°ããWeb ã¢ããªã±ã¼ã·ã§ã³ã§æåã¨ã³ã³ã¼ãã£ã³ã°ã«é¢é£ããåé¡ãç¡ããããã¨ãç®çã¨ãã¦ãå ¨ã¦ã® Web ã¢ããªã±ã¼ã·ã§ã³éçºè ã以ä¸ãå®è¡ãããã¨ãã主張ã ã¨æãã¾ãã
- å ¨ã¦ã®å ¥åæååã®æåã¨ã³ã³ã¼ãã£ã³ã°ã®å¦¥å½æ§ã確èªãã
- æåã¨ã³ã³ã¼ãã£ã³ã°ãå³æ ¼ã«åãæ±ã
- ãã¼ã¿ãã¼ã¹ãªã©ã§ããã¤ããªãã«è¿ãæåã¨ã³ã³ã¼ãã£ã³ã°ã¯å©ç¨ããªã
å人çã«ã¯ãPHP ã¯æåã¨ã³ã³ã¼ãã£ã³ã°é¢é£ã®å¦çã«ã¤ãã¦ãåé¡ãå¤ãã¨èãã¦ãã¾ããPHP å©ç¨è ããããã®åé¡ããã°ã¾ã§ç解ãã¦æ±ãã®ã¯ãããã«ç¡çãããã¨æãã¾ãã以åããã®æ¥è¨ã§ãåãä¸ãã¾ããããmb_check_encoding() ã ãã§ã PHP ã®ãã¼ã¸ã§ã³ã«ãã£ã¦ç¸å½ãªéããããã¾ããææ°ã® PHP ã§ã¯ããªãæ¹åããã¦ãã¾ãããã¾ã åé¡ã¯æ®ã£ã¦ãã¾ã(mb_check_encoding() ã®å é¨å¦ç)ããã®ãããåç´ã«å ¥åãã¼ã¿ã mb_check_encoding() ã§å¦¥å½æ§ã®ç¢ºèªãããã ãã§ã¯ãååã§ãªãå ´åãããã¾ãã
æåã¨ã³ã³ã¼ãã£ã³ã°ã«ã¤ãã¦ã¯ãmbstring ã®ãã㪠PHP ã®1ã¢ã¸ã¥ã¼ã«ã§å¯¾å¿ããã®ã§ã¯ãªããPHP èªä½ãæåã¨ã³ã³ã¼ãã£ã³ã°ãå³æ ¼ã«åãæ±ãããã«ããæ¹ãåé¡ãå°ãªããªãã¨æãã¾ããPHP6 ãã¹ãããã·ã§ãããããã¦ã³ãã¼ããã¦è©¦ãã¦ã¿ãã¨ãããæååãå¤æ°ã«ä»£å ¥ããã¨ãæåã¨ã³ã³ã¼ãã£ã³ã°ã®å¦¥å½æ§ã確èªãããããã«ãªã£ã¦ãã¾ãããPHP6 ã®å®æ度ãä¸ãã¦æ©æã«ãªãªã¼ã¹ããããã«ããæ¹ããã®åé¡ã®è§£æ±ºã«ã¯æ©éããããã¾ãããPHP6 ã®ãªãªã¼ã¹ã«ã¯ã¾ã ã¾ã æéããããããã§ããã
以ä¸ã«ã大å£ããææ¸ã®ä¸ã§æ°ã«ãªã£ããã¾ãã¯ãããåãããªãã£ããã¨ãæãã¦ããããã¨æãã¾ãã
å ¥åæã®èªåå¤æ
以ä¸ã®è¨è¿°ã§ã対çå¯è½ã¨æ¸ãã¦ãããã¾ããã注æãã¹ãç¹ã3ã¤ããã¾ãã®ã§ãæ¸ãã¦ããããã¨æãã¾ãã
追è¨:ãPHPã§æã£åãæ©ã対çããã«ã¯?ãã¨èãããã®ã§æ¸ãã¦ããã¾ããã¨ã³ããªä¸ã«ãæ¸ãã¦ãã¾ãããUTF-8ã®å ´åã¯
mbstrign.strict_detetion = on
mbstring.http_input = auto
mbstring.internal_encoding = utf-8
mbstring.http_output = passã¨ãã¾ãã(strict_detectionãå ¥ãå¿ãã¦ããã®ã§è¿½å ãã¦ãã¾ã)
http://blog.ohgaki.net/is-char-encoding-problem-difficult
(1) ééãã人ã¯å°ãªãã¨æãã¾ãããä¸è¨ã®è¨å®ã ãã§ã¯ãå
¥åæã®èªåå¤æã¯æå¹ã«ãªãã¾ãããmbstring.encoding_translation = On ãå¿
è¦ã§ãã
(2) mbstring.http_input ã« auto ãè¤æ°ã®æåã¨ã³ã³ã¼ãã£ã³ã°ãæå®ããã¨ãææªã®å ´åã¯ãå¤æãããã«ãã®ã¾ã¾å
¥åå¤æ°($_GET, $_POST ãªã©)ã«æ¸¡ã£ã¦ãã¾ããã¨ãããããã§ã(PHP 5.2.11 ã§ç¢ºèª)ãå
¥åå¤ã®ä¸æ£ãªæååãæé¤ãããã¨ãç®çã®å ´åãmbstring.http_input ã«æå®ããã®ã¯1ã¤ã ãã«ããæ¹ãè¯ãã¨æãã¾ããUTF-8 ã®å ´åã¯ã以ä¸ã®éãã§ãããã®å ´åãä¸æ£ãªæååã«ãªã£ã¦ããé¨åã®ã¿åé¤ããã¾ãã
mbstring.internal_encoding = UTF-8 mbstring.http_input = UTF-8 mbstring.encoding_translation = On mbstring.strict_detection = On
(3) PHP ã®ãã¼ã¸ã§ã³ã¨è¨å®ã«ãã£ã¦ã¯ãmbstring.strict_detection = On ã®æå®ã¯å±éºã§ããæ£ç¢ºã«ã¯ãPHP 5.1.2 ã PHP 5.2.8 ã§ã¯ãmbstring.http_input ã«è¤æ°ã®æåã¨ã³ã³ã¼ãã£ã³ã°ãè¨å®(auto ã®å ´åãå«ã)ãã¦ãä¸æ£ãªæååãå¤æãããã¨ããã¨ãç¡éã«ã¼ããçºçãã¾ãã以ä¸ã®ã³ã¼ãã§ç¡éã«ã¼ããçºçããå ´åã¯ãmbstring.strict_detection ã Off ã«ããããmbstring.http_input ã«è¤æ°ã®æåã¨ã³ã³ã¼ãã£ã³ã°ãæå®ããªãã§ãã ããã
<?php ini_set( 'mbstring.strict_detection', 1 ); mb_convert_variables( 'UTF-8', 'auto', $a = array( "\xfc" ) );
詳ããç¥ãããæ¹ã¯ã以ä¸ãåç §ãã¦ãã ããã
enctype="multipart/form-data" ãæå®ããå ´åã®èªåå¤æ
以ä¸ã®é¨åã«ã¤ãã¦ã§ãã
PHPã®å ´åã¯Perlãããã£ã¨ç°¡åã§ãã³ã¼ããä¸åæ¸ãæããªãã¦ãphp.iniã®è¨å®ãããã ãã§"èªå"ããªãã¼ã·ã§ã³ãè¡ãã¾ãã
http://blog.ohgaki.net/is-char-encoding-problem-difficult
ã¨èªåèªèº«ã§æ¸ãã¦ããªããä½æ ãæåã¨ã³ã³ã¼ãã£ã³ã°ã®ããªãã¼ã·ã§ã³ãå¿ ç¨ãªã®ã?ã¨çåã«æã£ãæ¹ãå± ãã¨æãã¾ããPHPã¯ãã¡ã¤ã«ã¢ãããã¼ããè¡ãå ´åã«ãã©ã¼ã ã«
enctype="multipart/form-data"
ãæå®ããã¨å ¥åã¨ã³ã³ã¼ãã£ã³ã°ã«èªåå¤æã¯åä½ããªãä»æ§ã«ãªã£ã¦ãã¾ããenctypeãéã£ã¦ãæ®éã®ãã£ã¼ã«ããéä¿¡ã§ãã¾ããããæåã¨ã³ã³ã¼ãã£ã³ã°å¤æãè¡ããªãããããã®ãã£ã¼ã«ãã«ã¯æ示çãªæåã¨ã³ã³ã¼ãã£ã³ã°å¤æãå¿ ç¨ã§ããã¤ã¾ããæ示çãªããªãã¼ã·ã§ã³ãå¿ ç¨ã«ãªãã¾ãã
ãenctype="multipart/form-data" ãæå®ããã¨ãå ¥åã¨ã³ã³ã¼ãã£ã³ã°ã§èªåå¤æãåä½ããªãä»æ§ãã¨æ¸ãã¦ãããã¾ãããPHP ããã¥ã¢ã«ã«ã¯ã以ä¸ã®ããã«è¨è¿°ããã¦ãã¾ãã
注æ: PHP 4.3.2 ããã³ãã以åã®ãã¼ã¸ã§ã³ã®å ´åãHTML ãã©ã¼ã ã®enctype ã multipart/form-data ã«è¨å®ãããå ´åãmbstring ã¯ãPOST ãã¼ã¿ã®æåã¨ã³ã³ã¼ãã£ã³ã°ãå¤æãã¾ããããã®å ´åãæååãå é¨æåã¨ã³ã³ã¼ãã£ã³ã°ã«å¤æãã¦ããå¿ è¦ãããã¾ãã
http://php.net/mbstring.http
PHP 4.3.3 以éãHTML ãã©ã¼ã ã® enctype ã multipart/form-data ã«è¨å®ããããã¤ãphp.ini ã«ãã㦠mbstring.encoding_translation ã« On ãæå®ããã¦ããå ´åãPOST ãã¼ã¿ã®å¤æ°ã¨ã¢ãããã¼ãããããã¡ã¤ã«ã®ååã®æåã¨ã³ã³ã¼ãã£ã³ã°ã¯ãå é¨æåã¨ã³ã³ã¼ãã£ã³ã°ã«å¤æããã¾ãããã ããã¯ã¨ãªãã¼ã«é¢ãã¦ã¯ãå¤æããã¾ããã
ããã¥ã¢ã«ã§ã¯ããPHP 4.3.3 以éã§ã¯ãphp.ini 㧠mbstring.encoding_translation = On ã«è¨å®ããenctype="multipart/form-data" 㧠HTML ãã©ã¼ã ãéãã¨ãå
é¨æåã¨ã³ã³ã¼ãã£ã³ã°ã«å¤æãããã¨èªãã¾ããå®éã試ãã¦ã¿ãã¨ãããPHP 4.4.9 ã§ã¯ãenctype="multipart/form-data" 㧠HTML ãã©ã¼ã ãéã£ã¦ããèªåçã«æåã¨ã³ã³ã¼ãã£ã³ã°ãå
é¨ã¨ã³ã³ã¼ãã£ã³ã°ã«å¤æããã¾ãããä»æ§ã¨ãã¦ã¯ãããã¥ã¢ã«ã§æ£ããã¨æãã¾ãã
ãã ããPHP 5.2.11 ã PHP 5.3.0 ã§ã¯ãå¤æããã¾ããã§ããããã®ä»¶ã«ã¤ãã¦ã¯ã以ä¸ã§å ±åããã¦ãã¾ããããçµå±ä¿®æ£ãããªãã£ãããã§ãã
mbstring ãããã©ã«ãã¢ã¸ã¥ã¼ã«ã«ãªã£ãã®ã¯ãPHP 4.0.6 ãã
PHP 4.2ããmbstringã¯ããã©ã«ãã¢ã¸ã¥ã¼ã«ã¨ãªãã¾ãããããã©ã«ãã¢ã¸ã¥ã¼ã«ãã¹ãã¨ææ¡ããã®ã¯ç§ã ã£ãã®ã§ããè¦ãã¦ãã¾ãã mbstringã«ã¯ã¤ã³ããããèªåçã«å é¨æåã¨ã³ã³ã¼ãã£ã³ã°å¤æããæ©è½ã¨ã¢ã¦ããããã«æå®ããæåã¨ã³ã³ã¼ãã£ã³ã°ãèªåå¤æããæ©è½ãæã£ã¦ãã¾ãã
http://blog.ohgaki.net/is-char-encoding-problem-difficult
mbstring ã¯ã4.0.6 ã§å°å ¥ãããã¨è¨æ¶ãã¦ãã¾ããPHP 4.2.0 ã§ã¯ãmbregex(ãã«ããã¤ãæ£è¦è¡¨ç¾ã¢ã¸ã¥ã¼ã«) ãå°å ¥ããã¾ããã
誤åã»è±åã«ã¤ãã¦
大å£ããã®æç« ã«ã以ä¸ã®ãããªè¨è¿°ãããã¾ããã
ä¹ ãã¶ãã«ã¢ãã¾ã³ã®ã¬ãã¥ã¼è¦ã¾ããããã»ãã¨é ·ãè©ä¾¡ï¼è¦ç¬ã§ãã»ãã¥ãªãã£æ¨æºãèªãã äºããããããã¦ååãå 容ãæ£ãã解説ã§ããWebéçºè ã¯ãããåã«ããã¨ã¯æãã¾ããã誤åã»è±åã¯èªåã§ãè¦ã¤ãã¾ããããããããæ¬ã®è©ä¾¡ã«éè¦ãªã®ã§ããããï¼å 容ãæ£ãããã©ããã¯æè¡è ã§ããã°å¤æã§ããã¨æãã¾ããããããã¦ã³ã¼ãç£æ»ã§é ·ãç®ã«åããã¦ãã¾ã£ãæ¹ãªã®ããªï¼ï¼æ±
http://blog.ohgaki.net/char_encoding_must_be_validated
å人çã«ã¯ãæ¬ãè²·ãéã«èª¤åã»è±åãçµæ§æ°ã«ããæ¹ãªã®ã§ã誤åã»è±åãç®ç«ã¤æ¬ã¯ãã¾ãè²·ãã¾ãããããã¯ãéè¦ãªé¨åã«ã¾ã§ééããããããã§ä¿¡ç¨ã§ããªããªãããã§ãããå
容ãæ£ãããã©ããã¯æè¡è
ã§ããã°å¤æã§ãããã¨ã®ãã¨ã§ãããåå¼·ã®ããã«æ¬ãè²·ã人ã«å¯¾ãã¦ãããæå¾
ããã®ã¯é
·ãªæ°ããã¾ãã
ã¾ãããã¾ã人ã«ããããã«è¨ãããç«å ´ã§ã¯ãªãã®ã§ããã大å£ããã®ææ¸ã¯ã誤åã»è±åãªã©ã®ééããå¤ããããªæ°ããã¾ãã誰ã§ããå°ããããã¯èª¤åã»è±åããããã®ã§ããããã¾ãç¥çµè³ªã«ãªããã¨ã¯ãªãã¨æãã®ã§ããããã¾ãã«å¤ãã¨ææ¸å
¨ä½ãä¿¡ç¨ã§ããªããªãæ°ããã¾ãããããã©ãã ãè¯ãææ¸ã ã£ããã¨ãã¦ããèªè
ããä¿¡ç¨ããªãã¨ã主張ã¯ä¼ãããªãã¨æãã¾ãã
ã³ã¡ã³ãã¸ã®è¿ä¿¡(2009.09.22)
大å£ãããã以ä¸ã®ã³ã¡ã³ããããã ãã¾ããããå°ãé·ããªãã®ã§ãã¡ãã§è¿ä¿¡ãã¾ãã
enctype="multipart/form-data" ãæå®ãããå ´åã®èªåå¤æã«ã¤ãã¦
mbstringã«ãããããåé¡ãããã®ã¯ç¢ºãã§ããPHP4.4.9ã®åä½ã¯ã©ããã¦ãããªã£ã¦ããã®ããåç´ãªæéãã§ä»æ§ãå¤ãã¦ãã¾ã£ãã ãã ã¨æãã¾ããmbstringã¯ç¢ºãã¤ãã ããã¨ãã£ãããæ¹ãphp3-i18nçãã¢ã¸ã¥ã¼ã«åãã¦ä½ã£ãç©ã§ãããã®å ã®mbstringã®ä»æ§ãmultipart/form-dataã«ãªã£ã¦ããã¨ã¨ã³ã³ã¼ãã£ã³ã°å¤æããªãã£ãã¨è¨æ¶ãã¦ãã¾ããPHP3ããã®ãããªä»æ§ã ã£ãã®ããç¥ãã¾ãããããã¶ãåã«å¤æããªããã¨ããã°ã¨ãã¦ã¬ãã¼ããããå ´åã«ããã®ä»æ§ã©ããããã¨ããè°è«ã«ãªã£ã¦ãã®ã¾ã¾ã«ãããã¨ã«ãªã£ãã®ã§ããã®çµç·¯ãç¥ã£ã¦ãã人ã«ã¯ãã°ã§ãã(ãåç¥ã¨ã¯æãã¾ããPHPã«ã¯ããããå¤æ´ãã¡ããã¡ããããã¾ã)
éå»ã® PHP-users ã PHP-dev ã¡ã¼ãªã³ã°ãªã¹ãã§ã®æµãã¨ãcvs.php.net ã®ãã°ãè¦ãã¨ã以ä¸ã®2ç¹ãèªã¿åããã¨æãã¾ãã
- PHP 4.3.3 ãã 4.3.5 ããã㧠enctype="multipart/form-data" ãæå®ããå ´åãå é¨ã¨ã³ã³ã¼ãã£ã³ã°ã«å¤æããæ©è½ã追å ãããã¨
- php3-i18n çã§ã enctype="multipart/form-data" ãæå®ãããå ´åãå é¨ã¨ã³ã³ã¼ãã£ã³ã°ã«èªåå¤æããã¦ãããã¨
ä»åããã¡ã¤ã«ã¢ãããã¼ãããããã¡ã¤ã«åã®æåã³ã¼ãã
http://ml.php.gr.jp/pipermail/php-users/2003-July/017633.html
å é¨æåã³ã¼ãã«å¤æããã³ã¼ãã追å ãã¦ãã¾ãã®ã§ã
ãã®è¾ºããã¹ããã¦ããã ããã¨ãããããã§ãã
multipart/form-dataã®å¤æ°åãå é¨æåã³ã¼ãã«å¤æããã®ã¯ã
http://ml.php.gr.jp/pipermail/php-users/2003-August/018109.html
encoding_translation = On ã®æã®åä½ã¨ãã¦å¦¥å½ãªã¨ããã ã¨æãã¾ãã
ã¾ããPHP3-i18nã®æåã¨åçã«ãªã£ãã®ã§ã¯ãªããã¨æãã¾ãã
å¾ãPHP3-i18nã§ç¢ºèªãã¦ã¿ãã¨ãããnameå±æ§ã«æ¥æ¬èªã使ã£ãå ´åã
http://ml.php.gr.jp/pipermail/php-users/2003-August/018123.html
æ£å¸¸ã«å¤æãã¦ããããã§ãã
cvs.php.net ã«ã¯ã以ä¸ã®ãããªãã°ãæ®ã£ã¦ãã¾ãã
bug fixed: name parameter of multipart form was not converted into internal encoding when mbstring.encoding_translation is on.
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?view=log#rev1.122.2.15
name/value in multipart/form-date will be converted into internal encoding when mbstring.encoding_translation is On.
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?view=log#rev1.142
ã¾ãã[PHP-dev 913]multipart/form-dataæã®encoding_translationã®ä»æ§ã«ã¤ãã¦ããå§ã¾ãã¹ã¬ãããåèã«ãªãã¾ãã
以ä¸ããããenctype="multipart/form-data" ãæå®ãããå ´åãèªåå¤æãè¡ãããã®ã¯ä»æ§ã§ãããã¨ããç解ã§æ£ããã®ã§ã¯ãªããã¨æãã¾ãã
mbstring ã PHP ã«å«ã¾ããããã«ãªã£ããã¼ã¸ã§ã³
mbstringã¯PHP 4.0.xãã使ããã®ã§ãPHPããã¸ã§ã¯ãã®ã½ã¼ã¹çã«å ¥ã£ãã®ã4.2ããã§ãã
mbstring ã®å®è¡æè¨å®(PHP ããã¥ã¢ã«) ãããã®ä»ã®é¢æ°ã§ã確èªã§ããããã«ãPHP 4.0.6 ãã mbstring ã使ç¨ã§ãããã¨ãè¨è¿°ããã¦ãã¾ããã¾ããmuseum.php.net ãã PHP 4.0.6 ããã¦ã³ãã¼ãããconfigure --help ã§ç¢ºèªããã¨ããã--enable-mbstring ãªãã·ã§ã³ãããã¾ããã
cvs.php.net ã確èªãã¦ã PHP 4.0.6 ã®ã¿ã°ãããã¾ãã®ã§ãmbstring ãå«ã¾ããããã«ãªã£ãã®ã¯ PHP 4.0.6 ããã§ééããªãã¨æãã¾ãã
追è¨(2009.10.13)
誤åã»è±åãä¿®æ£ãã¾ããã