<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Magic Quotes Headaches</title>
	<atom:link href="http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<lastBuildDate>Mon, 23 Nov 2009 00:15:13 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: eddie thieda</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-810615</link>
		<dc:creator>eddie thieda</dc:creator>
		<pubDate>Fri, 17 Oct 2008 14:02:55 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-810615</guid>
		<description>Thanks for the quick fix it!

I really appreciate your time to share this valuable information.

[E]</description>
		<content:encoded><![CDATA[<p>Thanks for the quick fix it!</p>
<p>I really appreciate your time to share this valuable information.</p>
<p>[E]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: phpdevel</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-615426</link>
		<dc:creator>phpdevel</dc:creator>
		<pubDate>Mon, 28 Jan 2008 22:42:07 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-615426</guid>
		<description>A direct quote from PHP.net:
&quot;An example use of stripslashes() is when the PHP directive magic_quotes_gpc  is on (it&#039;s on by default), and you aren&#039;t inserting this data into a place (such as a database) that requires escaping. For example, if you&#039;re simply outputting data straight from an HTML form.&quot;
 - http://us3.php.net/stripslashes

NOTICE: magic_quotes_gpc is on BY DEFAULT!!!!  A word of advice, do not make assumptions, check your PHP.ini using phpinfo() to determine your PHP configuration.  Site Admins aren&#039;t necessarily PHP pros, and therefore may not understand PHP directives, and unwittingly make alterations to a default PHP.ini.  As a developer every site is unique, look at this site, for example, they explicitly ask that you escape a post to this forum. (smart or not) security through obscurity?  Check your own input... don&#039;t assume yours will behave the same as Joe&#039;s or Eddie&#039;s because they said thats how theirs was set up, so thats how yours will be set up.  This is exactly my problem now, I was assuming my input was handled one way when in fact it was being handled another... didn&#039;t notice it until someone asked me about a formatting problem. oops (take my own advise)</description>
		<content:encoded><![CDATA[<p>A direct quote from PHP.net:<br />
&#8220;An example use of stripslashes() is when the PHP directive magic_quotes_gpc  is on (it&#8217;s on by default), and you aren&#8217;t inserting this data into a place (such as a database) that requires escaping. For example, if you&#8217;re simply outputting data straight from an HTML form.&#8221;<br />
 &#8211; <a href="http://us3.php.net/stripslashes" rel="nofollow">http://us3.php.net/stripslashes</a></p>
<p>NOTICE: magic_quotes_gpc is on BY DEFAULT!!!!  A word of advice, do not make assumptions, check your PHP.ini using phpinfo() to determine your PHP configuration.  Site Admins aren&#8217;t necessarily PHP pros, and therefore may not understand PHP directives, and unwittingly make alterations to a default PHP.ini.  As a developer every site is unique, look at this site, for example, they explicitly ask that you escape a post to this forum. (smart or not) security through obscurity?  Check your own input&#8230; don&#8217;t assume yours will behave the same as Joe&#8217;s or Eddie&#8217;s because they said thats how theirs was set up, so thats how yours will be set up.  This is exactly my problem now, I was assuming my input was handled one way when in fact it was being handled another&#8230; didn&#8217;t notice it until someone asked me about a formatting problem. oops (take my own advise)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: SoreGums</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-298202</link>
		<dc:creator>SoreGums</dc:creator>
		<pubDate>Mon, 09 Jul 2007 06:42:53 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-298202</guid>
		<description>Man I&#039;ve run into major problems with magic quotes, thanks to the comments above from Ren its all fixed!

Thanks...

Man I can&#039;t wait to get my head around JBoss Seam - I&#039;ve always tried to not do anything in PHP but this project needed to be producing results straight away and I had no choice but to start using PHP :(</description>
		<content:encoded><![CDATA[<p>Man I&#8217;ve run into major problems with magic quotes, thanks to the comments above from Ren its all fixed!</p>
<p>Thanks&#8230;</p>
<p>Man I can&#8217;t wait to get my head around JBoss Seam &#8211; I&#8217;ve always tried to not do anything in PHP but this project needed to be producing results straight away and I had no choice but to start using PHP :(</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-212421</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 27 Mar 2007 07:19:25 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-212421</guid>
		<description>PHP is one of the most incompetently designed languages ever. Sad but true.</description>
		<content:encoded><![CDATA[<p>PHP is one of the most incompetently designed languages ever. Sad but true.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-209036</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 22 Mar 2007 04:30:23 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-209036</guid>
		<description>Stellar! Saved my ass, thanks for the stripslashes code.</description>
		<content:encoded><![CDATA[<p>Stellar! Saved my ass, thanks for the stripslashes code.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: NoOne</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-36475</link>
		<dc:creator>NoOne</dc:creator>
		<pubDate>Tue, 11 Jul 2006 04:19:50 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-36475</guid>
		<description>From PHP Manual recursive stripslashes code:
&lt;code&gt;
if (get_magic_quotes_gpc()) {
   function stripslashes_deep($value)
   {
       $value = is_array($value) ?
                   array_map(&#039;stripslashes_deep&#039;, $value) :
                   stripslashes($value);

       return $value;
   }

   $_POST = array_map(&#039;stripslashes_deep&#039;, $_POST);
   $_GET = array_map(&#039;stripslashes_deep&#039;, $_GET);
   $_COOKIE = array_map(&#039;stripslashes_deep&#039;, $_COOKIE);
}
&lt;/code&gt;

NoOne, </description>
		<content:encoded><![CDATA[<p>From PHP Manual recursive stripslashes code:<br />
<code>
if (get_magic_quotes_gpc()) {
   function stripslashes_deep($value)
   {
       $value = is_array($value) ?
                   array_map('stripslashes_deep', $value) :
                   stripslashes($value);

       return $value;
   }

   $_POST = array_map('stripslashes_deep', $_POST);
   $_GET = array_map('stripslashes_deep', $_GET);
   $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
</code></p>
<p>NoOne, </p>]]></content:encoded>
	</item>
	<item>
		<title>By: NoOne</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-36471</link>
		<dc:creator>NoOne</dc:creator>
		<pubDate>Tue, 11 Jul 2006 04:15:15 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-36471</guid>
		<description>From PHP Manual recursive stripslashes code:
&lt;code&gt;&lt;/code&gt;

NoOne, </description>
		<content:encoded><![CDATA[<p>From PHP Manual recursive stripslashes code:<br />
<code></code></p>
<p>NoOne, </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-1921</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-1921</guid>
		<description>&lt;p&gt;A little more in-depth treatment of this topic, including code to detect and reverse the effects of all three magic_quotes settings, can be found here:&lt;/p&gt;

&lt;p&gt;http://education.nyphp.org/phundamentals/PH_storingretrieving.php&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>A little more in-depth treatment of this topic, including code to detect and reverse the effects of all three magic_quotes settings, can be found here:</p>
<p><a href="http://education.nyphp.org/phundamentals/PH_storingretrieving.php" rel="nofollow">http://education.nyphp.org/phundamentals/PH_storingretrieving.php</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Knowles</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-1922</link>
		<dc:creator>Alan Knowles</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-1922</guid>
		<description>&lt;p&gt;Yes Magic Quotes are evil :)&lt;br /&gt;
The example code introduces nighmares for using any library that may interact with input variables (which is not usually a good idea anyway).&lt;/p&gt;

&lt;p&gt;It&#039;s far better to add this to the start of the application, than even bothering trying to deal with them..&lt;br /&gt;
if (get_magic_quotes_gpc()) {&lt;br /&gt;
   trigger_error(&quot;Turn of magic quotes in php.ini / .htaccess or apache config&quot;, E_USER_ERROR);&lt;br /&gt;
} &lt;br /&gt;
&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Yes Magic Quotes are evil :)<br />
The example code introduces nighmares for using any library that may interact with input variables (which is not usually a good idea anyway).</p>
<p>It&#8217;s far better to add this to the start of the application, than even bothering trying to deal with them..<br />
if (get_magic_quotes_gpc()) {<br />
   trigger_error(&#8221;Turn of magic quotes in php.ini / .htaccess or apache config&#8221;, E_USER_ERROR);<br />
} </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Skunk</title>
		<link>http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/comment-page-1/#comment-1923</link>
		<dc:creator>Skunk</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">78497610#comment-1923</guid>
		<description>&lt;p&gt;The library thing is the killer as far as I&#039;m concerned. Basically, the magic quotes issue makes it all but impossible to write code for other people to re-use (unless the code has no interactions at all with the outside world). If you write it expecting a specific setting for magic_quotes and the end user has a different setting you&#039;ll get horrible problems.&lt;/p&gt;

&lt;p&gt;Avoiding user input isn&#039;t a very pretty option either, since your library functions may be passed strings from input by the user which are in an &quot;unknown&quot; state - they might be escaped, they might not be. Alan&#039;s suggestion of dying if magic qutoes are on isn&#039;t a terrible idea, but if a user already has a large code base that expects the feature to be on they will be unable to use your library without a major rewrite (although maybe that&#039;s not a bad thing). That said, many users on shared hosting don&#039;t have access to php.ini OR htaccess files, and it&#039;s a little harsh expecting them to change hosts just to reuse your code.&lt;/p&gt;

&lt;p&gt;The most annoying thing about this all is that magic quotes is actually a very poor solution to the database escaping problem. Firstly, different databases have different escaping rules (I think SQL server requires quotes to be doubled up rather than backslash escaped). Secondly, a far, far more reliable way of safely escaping database variables used be pretty much databases access libraries for loads of other languages is to use something like this:&lt;/p&gt;

&lt;p&gt;$query = sql_query(&quot;select * from table where tag = ? and section = ?&quot;, $tag, $section);&lt;/p&gt;

&lt;p&gt;In magic quotes defence, if the above were used there would always be utterly clueless newbies who still stuck everything together using string concatenation and opened them up to vulnerabilities, but a decent sized warning against this on the manual page for the function would probably be enough to save all but the most hopeless of cases.&lt;/p&gt;

&lt;p&gt;This turned in to a bit of a rant, but magic quotes is one of the principle things that turned me away from PHP for large web application development (I use Python now) so it&#039;s something of a pet peeve!&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>The library thing is the killer as far as I&#8217;m concerned. Basically, the magic quotes issue makes it all but impossible to write code for other people to re-use (unless the code has no interactions at all with the outside world). If you write it expecting a specific setting for magic_quotes and the end user has a different setting you&#8217;ll get horrible problems.</p>
<p>Avoiding user input isn&#8217;t a very pretty option either, since your library functions may be passed strings from input by the user which are in an &#8220;unknown&#8221; state &#8211; they might be escaped, they might not be. Alan&#8217;s suggestion of dying if magic qutoes are on isn&#8217;t a terrible idea, but if a user already has a large code base that expects the feature to be on they will be unable to use your library without a major rewrite (although maybe that&#8217;s not a bad thing). That said, many users on shared hosting don&#8217;t have access to php.ini OR htaccess files, and it&#8217;s a little harsh expecting them to change hosts just to reuse your code.</p>
<p>The most annoying thing about this all is that magic quotes is actually a very poor solution to the database escaping problem. Firstly, different databases have different escaping rules (I think SQL server requires quotes to be doubled up rather than backslash escaped). Secondly, a far, far more reliable way of safely escaping database variables used be pretty much databases access libraries for loads of other languages is to use something like this:</p>
<p>$query = sql_query(&#8221;select * from table where tag = ? and section = ?&#8221;, $tag, $section);</p>
<p>In magic quotes defence, if the above were used there would always be utterly clueless newbies who still stuck everything together using string concatenation and opened them up to vulnerabilities, but a decent sized warning against this on the manual page for the function would probably be enough to save all but the most hopeless of cases.</p>
<p>This turned in to a bit of a rant, but magic quotes is one of the principle things that turned me away from PHP for large web application development (I use Python now) so it&#8217;s something of a pet peeve!</p>]]></content:encoded>
	</item>
</channel>
</rss>
