[Svn-src-all:873] [version-2_5-dev 19760] #771(magic_quotes_gpc が有効な環境を考慮する)実装

Seasoft admin @ mail.ec-cube.net
2010年 12月 25日 (土) 14:31:07 JST


Subversion committed to /home/svn/open 19760
http://svn.ec-cube.net/open_trac/changeset/19760
┌────────────────────────────┐
│更新者 :  Seasoft                                      │
│更新日時:  2010-12-25 14:31:06 +0900 (土, 25 12月 2010)│
└────────────────────────────┘

Log:
--------------------------------------------------------
#771(magic_quotes_gpc が有効な環境を考慮する)実装

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_5-dev/data/class/SC_Initial.php
U   branches/version-2_5-dev/html/install/index.php

変更: branches/version-2_5-dev/data/class/SC_Initial.php
===================================================================
--- branches/version-2_5-dev/data/class/SC_Initial.php	2010-12-24 09:09:50 UTC (rev 19759)
+++ branches/version-2_5-dev/data/class/SC_Initial.php	2010-12-25 05:31:06 UTC (rev 19760)
@@ -58,6 +58,7 @@
         $this->defineConstants();
         $this->mbstringInit();
         $this->createCacheDir();
+        $this->stripslashesDeepGpc();
         $this->resetSuperglobalsRequest();
     }
 
@@ -318,6 +319,34 @@
     }
 
     /**
+     * クォートされた文字列のクォート部分を再帰的に取り除く
+     *
+     * {@link http://jp2.php.net/manual/ja/function.get-magic-quotes-gpc.php PHP Manual} の記事を参考に実装。
+     * $_REQUEST は後続の処理で再構成されるため、本処理では外している。
+     * @return void
+     */
+    function stripslashesDeepGpc() {
+        // Strip magic quotes from request data.
+        if (get_magic_quotes_gpc()) {
+            // Create lamba style unescaping function (for portability)
+            $quotes_sybase = strtolower(ini_get('magic_quotes_sybase'));
+            $unescape_function = (empty($quotes_sybase) || $quotes_sybase === 'off') ? 'stripslashes($value)' : 'str_replace("\'\'","\'",$value)';
+            $stripslashes_deep = create_function('&$value, $fn', '
+                if (is_string($value)) {
+                    $value = ' . $unescape_function . ';
+                } else if (is_array($value)) {
+                    foreach ($value as &$v) $fn($v, $fn);
+                }
+            ');
+
+            // Unescape data
+            $stripslashes_deep($_POST, $stripslashes_deep);
+            $stripslashes_deep($_GET, $stripslashes_deep);
+            $stripslashes_deep($_COOKIE, $stripslashes_deep);
+        }
+    }
+
+    /**
      * スーパーグローバル変数「$_REQUEST」を再セット
      *
      * variables_order ディレクティブによる差を吸収する。

変更: branches/version-2_5-dev/html/install/index.php
===================================================================
--- branches/version-2_5-dev/html/install/index.php	2010-12-24 09:09:50 UTC (rev 19759)
+++ branches/version-2_5-dev/html/install/index.php	2010-12-25 05:31:06 UTC (rev 19760)
@@ -436,6 +436,11 @@
         $hasErr = true;
     }
 
+    if (get_magic_quotes_gpc()) {
+        $mess .= ">> ×:PHPの設定ディレクティブ「magic_quotes_gpc」が有効になっています。<br>";
+        $hasErr = true;
+    }
+
     // 問題点を検出している場合
     if ($hasErr) {
         $objPage->tpl_mode = 'return_step0';




Svn-src-all メーリングリストの案内