â
â data uriå¤ææ©
ããã¯ãããã¾ãããªãã»ã©ãã
data:text/html;charset=utf-8;base64,aHR0cDovL2xhLm1hLmxhL21pc2MvanMvZGF0YS5odG1s
â Firefoxã§Windowsã®ã¯ãªãããã¼ãã«å¤ãè¨å®ããæ¹æ³
ä¸ãè¸ã¾ãã¦ã
Opera8.5ã§ãããã¦ãæ°ããã¾ãã
å¤é¨ã®ãµã¼ããå©ç¨ããã«HTMLåä½ã§ããã¦ããã®ã¯ãdataã¹ãã¼ã ãæå¹ã ããã§ãããIE7ã§ã¯ã¾ã dataã¹ãã¼ã ã£ã¦æå¹ãããªãã®ã§ããã£ãï¼
ãï¼ãªã¼ãã¼ããã¼ãããã£ã¦ï¼ããªãã§ããï¼ç¬ï¼
- Firefoxã§ããã¹ããã¯ãªãããã¼ãã«ã³ãã¼ããæ¹æ³::æéã¤ã³ã¿ã¼ãã§ã¼ã¹ç 究ä¼
- Javascript ï¼ï¼ Flash ã§ã¯ãªãããã¼ãã«ã³ãã¼::AUSGANG SOFT
ã¯ãªãããã¼ãã«æ¸ãè¾¼ãåä½ãããActionScriptãåãè¾¼ãã swfãã¡ã¤ã«ãdataã¹ãã¼ã ã§è¡¨ç¾ãã¦ããã®ã§ããã
â ãã¼ã¹ãããããã²ã¨ã¤ã®æ¹æ³
To paste the contents just use the SHIFT-INSERT keys instead of the ol' CTRL-V.
Firefoxã§CTRL-Vãåºæ¥ãªãã¨é¨ãã«ãªã£ããã¨ã£ã¦ãããã§ããã£ãï¼è£æã§SHIFT-INSERTã ã¨OKã ã£ãã¿ããã§ããã©ã
â PHP å©ç¨æã« Shift_JIS 㧠addslashes() ã«ããã¨ã¹ã±ã¼ãå¦çã«ãSQL ã¤ã³ã¸ã§ã¯ã·ã§ã³å¯è½ãªç©´
addslashes() ã«ãã SQL æååã®ã¨ã¹ã±ã¼ãåé¿åé¡
- addslashes() ã«ãã SQL æååã®ã¨ã¹ã±ã¼ãåé¿åé¡::t_komuraã®æ¥è¨
- The addslashes() Versus mysql_real_escape_string() Debate :: Chris Shiflett: The PHP Blog
- mysql_real_escape_string() versus Prepared Statements :: iBlog - Ilia Alshanetsky
対çã¨ãã¦ã¯ãPrepared Statement ã使ããã¾ãã¯ãmysql_real_escape_string() ãªã©ã®ãã¼ã¿ãã¼ã¹å°ç¨ã®ã¨ã¹ã±ã¼ãé¢æ°ã使ç¨ããã¨ããæ¹æ³ãããããã§ã(å®éã«ã¯è©¦ãã¦ãã¾ããã®ã§ã確èªããæ¹ãè¯ãã¨æãã¾ã)ã
So what can you do? The solution is to use prepared statements, which are supported by nearly all PHP database extensions with the notable exceptions of MySQL (ext/mysql) and SQLite2 (ext/sqlite). So, to be on the safe side, I'd recommend using the PDO interface to talks with those databases or in the case of MySQL using the newer MySQLi (ext/mysqli) extension. Those interfaces provide prepared statement support, which allows for separation between query structure and the query parameters. It should be noted that while PDO does emulated prepared statements for older versions of MySQL that do not support them natively, emulation is still prone to the same kind of issues demonstrated here and in Chrisâ article. Therefore for security reasons you should definitely consider upgrading to a more modern version of MySQL and SQLite (SQLite 3).
PHPã§ã¯ãä¸é¨ã®ãã«ããã¤ãã¨ã³ã³ã¼ãã£ã³ã°ã«ããã¦ãaddslashes()ã使ã£ã¦ããã¨SQLã¤ã³ã¸ã§ã¯ã·ã§ã³ãçºçããããªãããã¯ã¦ã©ããã¾ããããã¨ããã話ã
Chris Shiflett æ°ãä»°ããã¨ã§ã¯ãaddslashes()ã¯ä½¿ããã«ãmysql_real_escape_string()ã使ãã¾ãããã¨ããã㸠Ilia Alshanetsky æ°ãããããããmysql_real_escape_string()ã§ãé§ç®ã§ãPrepared Statements ã使ãã¾ããããã¨è¨ã£ã¦ãããããªæ°ããã¾ããä¸æ¹æ¥æ¬ã§ããã®ç¾è±¡ã«ã¤ãã¦è§¦ãã¦ããææ¸ãããã¾ãã
ãã¨ã大è¦æ¨¡æ¡ä»¶ã§ãçºçããSQL Injectionï¼SQLã¤ã³ã¸ã§ã¯ã·ã§ã³ï¼SQLã®æ¿å ¥ï¼ãSQLã¤ã³ã¸ã§ã¯ã·ã§ã³ã¨ã¯ãªã¯ã¨ã¹ãã®ãã©ã¡ã¼ã¿ã«SQLæãä¸ãã¦SQLãã¼ã¿ãã¼ã¹ãä¸æ£ã«æä½ããæ»æãã¾ãã¯ãã®æ»æãå¯è½ã«ããå ¥åå¤ã®æªãã§ãã¯ã®èå¼±æ§ã®ãã¨ãããã¾ãã
ãããé¿ããããã®å¦çã«addslashesã¨ããã®ãããã¾ããããaddslashesã ã¨ããããã¨åé¡ãèµ·ãã£ãããã¾ãã(SJISã®5Cåé¡ã¨ã)
ä»ã®ã¨ããããã¥ã¢ã«ã§ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ããã®ã§ããã
- ãã¼ã¿ãã¼ã¹ã«æ¸¡ãããæ°å¤ä»¥å¤ã®ã¦ã¼ã¶å ¥åã ãã¼ã¿ãã¼ã¹åºæã®æååã¨ã¹ã±ã¼ãé¢æ° (mysql_escape_string(), sql_escape_string(), ãªã©) ã§ã¯ãªã¼ããã¦ãã ããã ãã¼ã¿ãã¼ã¹åºæã®æååã¨ã¹ã±ã¼ãæ©è½ãå©ç¨ã§ããªãå ´åã addslashes() ããã³ str_replace()é¢æ°ãå©ç¨ã§ããã§ãããã (ãã¼ã¿ãã¼ã¹ã®åã«ä¾å) æåã®ä¾ãåç § ãã¦ãã ãããåæã®ä¾ã示ãããã«ãã¯ã¨ãªã®éçãªé¨åãã¯ãªã¼ã ããã ãã§ã¯å åã§ã¯ãªããç°¡åã«ã¯ã©ãã¯ããã¦ãã¾ãå¯è½æ§ãã ãã¾ãã
Ilia Alshanetsky æ°ãè¨ãããã«ããã¼ã¿ãã¼ã¹åºæã®æååã¨ã¹ã±ã¼ãé¢æ°ãaddslashes()ãé§ç®ã§ãPrepared Statements ã使ããªããããã¨ããã®ã¯ããã£ã¦ããã¨ãããã©ã®ãããããã®ããªãã
2006/02/13追è¨
çµè«ããè¨ãã¨ãShift_JISãç´ ç´ã«ä½¿ã£ã¦ããéããaddslashes()ã¯é§ç®(Chris Shiflettæ°)ãmysql_real_escape_string() ã¯é§ç®(Ilia Alshanetskyæ°)ãä¸é¨ã®Prepared Statements ãããé§ç®(id:jrofbyrsãã)ãã¨ãããã¨ãããã§ãã
ã¾ããid:jrofbyr ãããã以ä¸ã®ãããªã³ã¡ã³ããããã ãã¾ãããMySQL ã¯æå ã®ç°å¢ã«ã¤ã³ã¹ãã¼ã«ãã¦ãã¾ããã®ã§ã確èªã§ããªãã®ã§ãããmysql_real_escape_string() ã§ã PEAR ã® Prepared Statement ã§ãã¨ã¹ã±ã¼ããããªãå ´åãããããã§ãã
mysql_real_escape_string()ã§ãSET NAMES sjis;çãå®è¡ããå¾ã«ä½¿ãã¨2ãã¤ãç®ã®0x5Cæåãã¨ã¹ã±ã¼ããããªãããã§ããPEAR::DBã®DB_common::prepare() ã§ã¯MySQL使ç¨æã¯å é¨ã§mysql_real_escape_string()ã使ãããã®ã§ãã¨ã¹ã±ã¼ããããªãå ´åãããã¾ããã確ãç°å¢ã¯ PHP 4.4.1/MySQL 4.1.12ã§ããSET NAMES binary;ã§ãªãã¨ãåé¿ãã¦ã¾ãã
ã¾ããPostgreSQL ã§ã SET client_encoding TO 'SJIS' ãå®è¡ããã¨ãã®åé¡ã®å½±é¿ãåãããã¨ã確èªãã¾ãã
å®å ¨ãªå¯¾å¦æ¹æ³ã¨ãã¦ã¯ Shift_JIS ãªã©ã®æåã®æå¾ã®ãã¤ãã« \ ãå«ã¾ããå¯è½æ§ã®ããæåã³ã¼ãã使ç¨ããªããã¨ã§ãã
以ä¸ã§è¿½è¨çµããã§ãã
magic_quotes_gpcãã£ã¬ã¯ãã£ã
magic_quotes_gpcãã£ã¬ã¯ãã£ããONã«ãã¦ããã¨ãã»ã¨ãã©è³ãã¨ãããèªåçã«addslashesãã¦ãããããªãã®ã§ããâ¦ãã®è¾ºã©ãã§ããããï¼ãã°ããªãã§ããï¼å ã ãmagic_quotes_gpcãã£ã¬ã¯ãã£ãã¯OFFã§ã¨ããã®ãæ¿ããæ¨å¥¨ããã¦ããã¨ããã§ã¯ããã¾ããã
ãã¸ãã¯ã¯ãªã¼ãã¯ãPHPã¹ã¯ãªããã«å ¥åããããã¼ã¿ã èªåçã«ã¨ã¹ã±ã¼ãããæ©è½ã§ãã ã³ã¼ãã§ã¯ããã¸ãã¯ã¯ãªã¼ãããªãã«ã㦠å®è¡ããéå¿ è¦ãªæã«ãã¼ã¿ãã¨ã¹ã±ã¼ããããã¨ãæã¾ãã¾ãã
ãªã³ã®å ´åãå ¨ã¦ã®' (ã·ã³ã°ã«ã¯ãªã¼ã), " (ããã«ã¯ãªã¼ã), \ (ããã¯ã¹ã©ãã·ã¥)ããã³NULL æåãããã¯ã¹ã©ãã·ã¥ã§èªåçã«ã¨ã¹ã±ã¼ãããã¾ãã ããã¯ãaddslashes() ã®æ©è½ã¨åãã§ãã
æ¢å®å¤ãªã³ã§ãããå¤ãã®å ´åã«ãmagic_quotes_gpcããªãã«ãã¦ãå¿ è¦æã«addslashes()ãããã¦ããã®ããªããããã¨ãç¡è¶ãã£ã¦ãããªããããã¯ã¨ããããShif_JISã¯ãããããæååããå«ãããã®ã§æ¡ç¨ãããªã£ã½ãæ°ããã¾ãããã©ã
ãã«ããã¤ãæåå¦çã®æç¡ã«é¢ããããmagic_quotes_gpcãã£ã¬ã¯ãã£ã㯠æå¹ã«ãã¦ã¯ãããªãæ©è½ã§ããããªãããç¡å¹ã«è¨å®ããããã§ãã
magic_quotes_gpcãOnã«ããã¨ãCGIãã©ã¡ã¿ãShift_JIS ã§æ¸¡ãããã¨ãã«æååããçºçãã¦ãã¾ãããããããéªéã«ãªãã¨ããåé¡ãèµ·ãã¦ããããã ããã®ãããé ·ããã¨ã«ã magic_quotes_gpc ãOnã®PHPç°å¢ã§ãåããããªããã°ã©ã ãä½ããã¯ããã¯ã¨ç§°ãã¦ãPHPããã°ã©ã ã®åé ã§ãCGIãã©ã¡ã¿ã®å ¨é¨ã«å¯¾ãã¦ãstripcslashesãããããã¨ãããåå¦çãããä¸é¨ã®PHPããã°ã©ãã®éã§å®çªã¨ãªã£ã¦ããããã ï¼ãã®æ¬ã«æ¸ããã¦ããããã§ã¯ãªãï¼ã magic_quotes_gpc = On ããã stripcslashes ããããã¾ã htmlspecialchars ãã¦ã¿ããã¨ãã»ãã¨æ±ãPHPã³ã¼ãããããã Googleã§è¦ã¤ãããmagic_quotes_gpc 㯠Off ã§å¾¹åºãããã ããã
Prepared Statements (æºåæ¸ã¿SQLæ(ãã¤ã³ãã¡ã«ããºã )ã®å ´å)
PHPã§ã¯LIKEã«ä½¿ããªãï¼â¦
Prepared statementã¯SQL ã®ãã¸ãã¯ã¨ãã¼ã¿ãåé¢ãããã¨ã§ ã»ãã¥ãªãã£ãå¢å ãã¾ãããã¸ãã¯ã¨ãã¼ã¿ãåé¢ãããã¨ã§ãSQL ã¤ã³ã¸ã§ã¯ã·ã§ã³æ»æãåé¿ãããã¨ãã§ãã¾ãã
ãã ãããã£ããããã§ãPHPã®ã©ããã¦ã±ã«ã®ãèãã¦è¦ã¾ãã«ãã½ã¼ã¹ã¬ãã«ã§ãã¸ãã¯ã¨ãã¼ã¿ãããã¦æ··å¨ããã¦ããã¨ãããªã®ã§ãããããâ¦æ°ãç¥ããªããã¨ãã㧠Prepared Statementsã£ã¦å¦çãéããã ãã©ããããªã¨ãã®çºã«AJAXã¨ãï¼éï¼
2006/02/13追è¨ï¼
æå¾ã®æ段ã®ã¯ãã ã£ããPrepared Statementsã§ãé§ç®ããã¨ãã話ã«ãªã£ã¦ãã¾ãããâaddslashes() ã«ãã SQL æååã®ã¨ã¹ã±ã¼ãåé¿åé¡::t_komuraã®æ¥è¨
PEAR::DBã®DB_common::prepare() ã§ã¯MySQL使ç¨æã¯å
é¨ã§mysql_real_escape_string()ã使ãããã®ã§ãã¨ã¹ã±ã¼ããããªã
â¦ããããæ ¹æ¬çã«Shift_JISã£ã¦PHPã¨ç¸æ§ãæªããããª(æ±)
追è¨çµããã
â .NET Frameworksã«ã¦ãã¨ã¹ã±ã¼ããã¦ãSQLã¤ã³ã¸ã§ã¯ã·ã§ã³å¯¾çã«ãªããªãäºä¾
id:jrofbyrããã®ããããåã話ã§ãããã