Jump to content

Funny behaviour AddHandler


connectcase

Recommended Posts

Not sure if this is Apache or PHP related, but the guys at php.net told me it is not a bug but a feature, emphasizing I should read the section on "magic quotes" (which I did over and over again, but no answer). Anyway, magic quotes are OFF in the example below:

 

Adding the following to your .htaccess file: "AddHandler application/x-httpd-php .php"

 

parses all php files correctly regarding "slash-involved" functions like addslashes, mysql_real_escape_string etc.:

 

addslashes("O'Brien") results in "O\'Brien" (as it should be, right?)

 

Adding the 5 to the PHP handler in your .htaccess file: "AddHandler application/x-httpd-php5 .php"

 

results in 2 extra slashes:

 

addslashes("O'Brien") will now become "O\\\'Brien"

 

According to the documentation a function like mysql_real_escape_string should only add just 1 slash and not insert it into your database.

 

There are no other changes to configuration or php.ini whatsoever. I am on shared hosting, so can't change much anyway.

Searched the php.net bugreports, searched the manual, searched phpfreaks, Google etc. but no luck of finding an explanation.....

 

Thanks guys!

Link to comment
Share on other sites

You should still verify that by running phpinfo, AddHandler application/x-httpd-php5 could be loading a different php.ini which has magic quotes enabled.

 

Magic quotes has three different settings, which are

magic_quotes_gpc - this is will automatically escape quotes in GET, POST or COOKIE data

magic_quotes_runtime - this stetting will automatically escape strings returned from functions

magic_quotes_sybase - allows you to escape quotes as '' (two single quotes) rather than \' (rarely used).

 

Both of the above settings should be disabled.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.