2

magic_quotes_gpcが に設定されている場合、Magento はアポストロフィをエスケープしていますoff。に設定magic_quotes_gpcするとon、Magento はスラッシュの挿入を停止します。完全に後ろ向きです。

Magento にアポストロフィをエスケープさせることはできませんが、自分のサイトの他の部分 (vBulletin フォーラム、Wordpress ブログなど) に影響を与える可能性があるため、magic_quotes_gpc設定したくありません。on

注意すべき点 - Magento は常にこのように動作していたわけではなく、今日始まったばかりです。

編集: CMS ページの 1 つのレイアウト更新 XML に次のコードを追加した後に、動作が開始されました。

<!--<reference name="content">
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page"><action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
<block type="reports/product_viewed" name="home.reports.product.viewed" alias="product_viewed" template="reports/home_product_viewed.phtml" after="product_new"><action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
<block type="reports/product_compared" name="home.reports.product.compared" template="reports/home_product_compared.phtml" after="product_viewed"><action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
</reference>
<reference name="right">
<action method="unsetChild"><alias>right.reports.product.viewed</alias></action>
<action method="unsetChild"><alias>right.reports.product.compared</alias></action>
</reference>-->

奇妙な動作が始まった後、そのコードを削除しましたが、問題は解決しませんでした。

4

2 に答える 2

4

編集:私は問題を理解しました。Wordpress には、スラッシュを追加する独自の機能があることがわかりました。Wordpress バージョン 3.2.1 では、wp_magic_quotes()/wp-includes/load.php の 530 行目あたりに関数があります。

この問題を解決するために、関数内のすべてをコメントアウトしました (未定義の関数の呼び出しを防ぐために、関数自体ではありません)。エスケープされた引用符の問題が削除されました。私は大規模なテストを行っていませんが、私が理解していることから、これにより古い Wordpress プラグインが壊れる可能性があるため、注意してください。

これから行きます:

function wp_magic_quotes() {
    // If already slashed, strip.
    if ( get_magic_quotes_gpc() ) {
        $_GET    = stripslashes_deep( $_GET    );
        $_POST   = stripslashes_deep( $_POST   );
        $_COOKIE = stripslashes_deep( $_COOKIE );
    }

    // Escape with wpdb.
    $_GET    = add_magic_quotes( $_GET    );
    $_POST   = add_magic_quotes( $_POST   );
    $_COOKIE = add_magic_quotes( $_COOKIE );
    $_SERVER = add_magic_quotes( $_SERVER );

    // Force REQUEST to be GET + POST.
    $_REQUEST = array_merge( $_GET, $_POST );
}

これに:

function wp_magic_quotes() {
    // If already slashed, strip.
    /*if ( get_magic_quotes_gpc() ) {
        $_GET    = stripslashes_deep( $_GET    );
        $_POST   = stripslashes_deep( $_POST   );
        $_COOKIE = stripslashes_deep( $_COOKIE );
    }

    // Escape with wpdb.
    $_GET    = add_magic_quotes( $_GET    );
    $_POST   = add_magic_quotes( $_POST   );
    $_COOKIE = add_magic_quotes( $_COOKIE );
    $_SERVER = add_magic_quotes( $_SERVER );

    // Force REQUEST to be GET + POST.
    $_REQUEST = array_merge( $_GET, $_POST );*/
}
于 2011-08-10T04:31:04.443 に答える
0

At the top of app/code/core/Mage/Core/functions.php there is this:

if (get_magic_quotes_gpc()) {
    function mageUndoMagicQuotes($array, $topLevel=true) {
        $newArray = array();
        foreach($array as $key => $value) {
            if (!$topLevel) {
                $newKey = stripslashes($key);
                if ($newKey!==$key) {
                    unset($array[$key]);
                }
                $key = $newKey;
            }
            $newArray[$key] = is_array($value) ? mageUndoMagicQuotes($value, false) : stripslashes($value);
        }
        return $newArray;
    }
    $_GET = mageUndoMagicQuotes($_GET);
    $_POST = mageUndoMagicQuotes($_POST);
    $_COOKIE = mageUndoMagicQuotes($_COOKIE);
    $_REQUEST = mageUndoMagicQuotes($_REQUEST);
}

Just copy this file to local (app/code/local/Mage/Core/functions.php) and comment out the if statement so it will always run.

// if (get_magic_quotes_gpc()) {
    function mageUndoMagicQuotes($array, $topLevel=true) {
        $newArray = array();
        foreach($array as $key => $value) {
            if (!$topLevel) {
                $newKey = stripslashes($key);
                if ($newKey!==$key) {
                    unset($array[$key]);
                }
                $key = $newKey;
            }
            $newArray[$key] = is_array($value) ? mageUndoMagicQuotes($value, false) : stripslashes($value);
        }
        return $newArray;
    }
    $_GET = mageUndoMagicQuotes($_GET);
    $_POST = mageUndoMagicQuotes($_POST);
    $_COOKIE = mageUndoMagicQuotes($_COOKIE);
    $_REQUEST = mageUndoMagicQuotes($_REQUEST);
// }

This is required because WordPress checks if magic quotes is disabled, and if it is it runs magic quotes anyway. There are lengthy discussions on whether or not this should happen but the consensus is removing that functionality could open security holes in older plugins or themes that do not work around it, so don't expect WordPress to remove that functionality any time soon.

于 2014-11-28T21:07:28.523 に答える