Zen Cart Logo
Forums / General Questions / backslashes stripped from product description?

backslashes stripped from product description?

Locked

Views: 1,873

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
9 Sep 2009, 1:37 AM
#1
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

backslashes stripped from product description?

I have this weird problem in which everything I tried (including doubling doubling the backslashes) doesn't solve the problem: Zen-Cart seems to strip all backslashes from the product description.

Case in question: I am trying to include in the product description the following string:> \myfileserver\mynetworkshare

Upon entering the product description (via Admin console) the backslashes disappear!

I tried entering > \\myfileserver\mynetworkshare but this didn't help.

I tried using enclosing this in PHP's specialhtmlchars() and that didn't help either - It seems that Zen-Cart strips those backslashes just before being stored in the database.

Any idea how to overcome this?

Thanks!

9 Sep 2009, 3:29 AM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: backslashes stripped from product description?

Have you tried using \ instead of a backslash?

9 Sep 2009, 3:30 AM
#3
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: backslashes stripped from product description?

Ha ha that doesn't work I will put spaces in between the characters

Have you tried using '& # 9 2 ;' ? Without the spaces, obviously!

9 Sep 2009, 3:52 AM
#4
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

niccol:

Have you tried using '& # 9 2 ;' ? Without the spaces, obviously!
Yes, I did - didn't help either.

Before posting here, I tried searching the subject and found only one thread - unanswered really:

http://www.zen-cart.com/forum/showthread.php?t=80192

Is it possible that this is a bug in Zen-Cart?

9 Sep 2009, 11:55 AM
#5
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

I forgot to ask the obvious: Am I the only one having this problem? Can you also see (or reproduce) the problem on your systems by entering a product description with one or more backslashes?

9 Sep 2009, 12:34 PM
#6
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: backslashes stripped from product description?

No, it works fine on my test server. In other words if I enter\ I get a single . If I enter \\ I get two. Which is kind of what you would expect. Don't know enough about servers to really give you advice beyond that.....

9 Sep 2009, 1:17 PM
#7
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

niccol:

No, it works fine on my test server. In other words if I enter\ I get a single . If I enter \\ I get two. Which is kind of what you would expect.
This is what I would expect, too. Thank you Nick for your answers.

This is troubling. What could have I possibly done in my system that would have introduced this problem?

Could this be a PHP version or configuration issue? Something specific not to Zen-Cart but rather to my web host?

9 Sep 2009, 4:35 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: backslashes stripped from product description?

Do you have the backslashes disappearing when you first enter and save the text in your description? I know that if you edit a description after entering and saving it, special character formatting will often go away.

9 Sep 2009, 6:21 PM
#9
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

gjh42:

Do you have the backslashes disappearing when you first enter and save the text in your description?
Yes. That is exactly the case.

When I first enter 4 consecutive backslashes into the product description I can still see them intact:> \\fileserver\networkshare

Once I press the Preview button, every 2 backslashes turn into 1 - this is fine with me and I can understand and work with that:> \fileserver\networkshare

But then when I press the Update button, it seems that this "divide-by-two" process repeates:> \fileservernetworkshare
Note how the single backslash after Preview disappeared but the n after it didn't (i.e. it wasn't treated like a \n = newline but rather the backslash only disappeared).

Is this a PHP feature? A bug?

9 Sep 2009, 6:36 PM
#10
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,883
Plugin Contributions:
3

Re: backslashes stripped from product description?

Does this happen with the standard text box for the description, or are you using the html editor text box?

9 Sep 2009, 6:44 PM
#11
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

wilt:

Does this happen with the standard text box for the description, or are you using the html editor text box?Standard text box for the description.

In fact, as I was trying to type my workaround here (using HTML escape characters as one might find at theukwebdesigncompany.com/articles/entity-escape-characters.php) I found that the vBulletin input box here exhibits the same exact problem.

I am now convinced that this is a PHP "feature", not a Zen-Cart specific issue.

10 Sep 2009, 5:18 PM
#12
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

I think that I discovered where this problem comes from. In includes/templates/template_default/templates/tpl_product_free_shipping_info_display.php (line 80) the product description is echoed through a stripslashes() filter:

 <!--bof Product description -->
<?php if ($products_description != '') { ?>
<div id="productDescription" class="freeShip biggerText"><?php echo stripslashes($products_description); ?></div>
<?php } ?>
<!--eof Product description -->

I am sure that this stripslashes() filter was placed there for a good reason. Can you shed some light on this?

10 Sep 2009, 5:48 PM
#13
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: backslashes stripped from product description?

It got me curious why you were seeing a different effect from me so I had a look. This quote from the php manual may be the reason:

Note: If magic_quotes_sybase is on, no backslashes are stripped off but two apostrophes are replaced by one instead.

5 Nov 2009, 10:49 PM
#14
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

scatzc:

I think that I discovered where this problem comes from. In includes/templates/template_default/templates/tpl_product_free_shipping_info_display.php (line 80) the product description is echoed through a stripslashes() filter:

<!--bof Product description --> <?php if ($products_description != '') { ?> <div id="productDescription" class="freeShip biggerText"><?php echo stripslashes($products_description); ?></div> <?php } ?> <!--eof Product description --> ``` > I am sure that this stripslashes() filter was placed there for a good reason. Can you shed some light on this?

This "feature" is driving me nuts. Before hacking the PHP code to get rid of this, I would appreciate an explanation of the design consideration that led to placing stripslashes() there. I am assuming, of course, that it is not a bug but rather a thoughtful feature.

Thanks.

6 Nov 2009, 12:38 AM
#15
scatzc avatar

scatzc

New Zenner

Join Date:
Sep 2009
Posts:
79
Plugin Contributions:
0

Re: backslashes stripped from product description?

niccol:

Note: If magic_quotes_sybase is on, no backslashes are stripped off but two apostrophes are replaced by one instead.
Update: I managed to workaround the problem (I am leery about hacking stable code that has been running for years, without fully understanding design considerations):

I have been able to output a single backslash on the product description page by entering in the source HTML 8 consecutive bacslashes (eight!).

For two adjacent backslashes I had to enter 16 consecutive bacslashes...

Pretty amazing.