magento - 当 magic_quotes_gpc 设置为 off 时引号被转义

标签 magento magic-quotes-gpc

magic_quotes_gpc 设置为 off 时,Magento 会转义撇号。当我将 magic_quotes_gpc 设置为 on 时,Magento 停止插入斜杠。完全是倒退了。

我不能让 Magento 转义我的撇号,但我也不希望将 magic_quotes_gpc 设置为 on 因为我担心它可能产生的影响我网站的其他部分(vBulletin 论坛、Wordpress 博客等)。

请注意 - Magento 并不总是这样,只是从今天开始。

编辑:将以下代码添加到我的 CMS 页面之一的布局更新 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>-->

奇怪的行为开始后,我删除了该代码,但它没有解决问题。

最佳答案

编辑:我找到了问题所在。原来Wordpress有它自己的添加斜杠的功能。从 WordPress 版本 3.2.1 开始,您可以在/wp-includes/load.php 的第 530 行左右找到函数 wp_magic_quotes()

为了解决这个问题,我注释掉了函数内的所有内容(不是函数本身,以防止调用未定义的函数)。它消除了转义引号的问题。我还没有进行广泛的测试,但据我了解,这可能会破坏旧的 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 );*/
}

关于magento - 当 magic_quotes_gpc 设置为 off 时引号被转义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6990734/

相关文章:

magento - 如何在magento中以数组而不是html block 的形式获取消息

image - 如何在 TCPDF 中添加图像

php - 使用 php 和 magic quote 插入 HTML 代码

javascript - 如果没有 stripslashes,json_decode 将无法工作(WordPress 中的 magic_quotes)

php - 如何关闭共享主机上的魔术引号?

Magento - 限制某些客户群体的某些类别

magento - 如何在 magento 多站点上设置 SSL

Magento:如何覆盖管理js文件而不是在核心中编辑它?

PHP - 魔法引用 gpc 和 stripslashes 问题

aop - FLOW3 需要将 PHP 设置 "magic_quotes_gpc"设置为关闭。 (错误#1224003190)