2011-08-09 2 views
2

magic_quotes_gpcoff으로 설정되면 Magento는 아포스트로피를 이스케이프합니다. magic_quotes_gpcon으로 설정하면 Magento는 슬래시 삽입을 중단합니다. 완전히 거꾸로입니다.magic_quotes_gpc가 꺼져있을 때 쉼표가 이스케이프됩니다

내 어포 스트로피를 탈출 젠토를 가질 수 없습니다, 그러나 나는 또한 내가 내 사이트 (vBulletin에 포럼, 워드 프레스 블로그 등의 다른 부분에 미칠 수있는 영향에 대한 걱정 때문에 onmagic_quotes_gpc 세트를 가지고 싶지 않아).

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>--> 

이상한 행동이 시작되면, 그 코드를 제거하지만 해결되지 않았다 문제.

+0

오늘 서버를 어떻게 변경 했습니까? 이런 것들은 일반적으로 자발적으로 발생하지 않습니다. 또한 어떻게 테스트하고 있습니까? 우리가 재현하려고 시도 할 수있는 예제 코드? – Nick

+0

서버에서 아무 것도 변경되지 않았습니다. 변경 직전에 수행 한 유일한 작업은 CMS 페이지의 레이아웃 업데이트 XML에 일부 코드를 추가하는 것이 었습니다. 위의 코드를 추가했습니다. 그 전까지는 크롤러가이 CMS 페이지에 도달하지 못하도록 'robots.txt'를 약간 변경했습니다. 변화가 끝난 후에도 모든 것이 계속 잘되었습니다. – Nick

답변

4

편집 : 문제를 파악했습니다. 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);*/ 
} 
+0

이 작업은 가능하지만 a) Wordpress 코어를 패치하는 것은 결코 좋은 생각이 아닙니다. b) Magento와는 독립적으로 WordPress를 사용하려는 경우 GET 및 POST HTTP 매개 변수를 통해 Wordpress 보안 취약점을 열 수 있습니다.Magento의 일부로 Wordpress를 포함한다면, 플래그를 설정하고 wp_magic_quotes 함수 내에서 조건부 리턴을 원할 수 있습니다. 이것은 * 괜찮을 수도 있습니다. – Willster

+0

@Willster 저는 magento의 일부로 wordpress를 사용하면서 위에서 확장 할 수 있습니다. 그리고 위와 같은 문제가 발생했습니다. magento가 깨지는 것을 막을 수있는 방법으로 이것을 설정하는 방법을 배우는 것에 매우 흥미가 있습니다. –

0

응용 프로그램/코드/코어의 상단/마법사/핵심이있다/functions.php :

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); 
} 

그냥 (현지 응용 프로그램/코드에이 파일을 복사 /local/Mage/Core/functions.php) if 문을 주석 처리하여 항상 실행되도록하십시오.

// 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); 
// } 

이 필요 워드 프레스 확인하기 때문에 마법 따옴표를 사용할 수 있으며,이 경우 어쨌든 마법 따옴표를 실행하는 경우. 이 문제가 발생해야할지 여부에 대한 논의가 길지 만 그 기능을 제거하면 이전 플러그인이나 그 주위에서 작동하지 않는 테마의 보안 허점을 열 수 있으므로 WordPress에서 언제든지 해당 기능을 제거 할 것을 기대하지 마십시오.

관련 문제