Author Topic: ld-json and double quote in product descriptions  (Read 1551 times)

diri

  • Jr. Member
  • **
  • Posts: 107
  • VirtueMart Version: most recent dev version (trunk)
ld-json and double quote in product descriptions
« on: November 23, 2019, 09:03:46 am »
Long standing issue:

To get correct ld-json double quotes should be escaped in sublayouts/snippets.php.

Something like
Code: [Select]
  "description":"<?php $escdescription str_replace('"','\"',$description); echo $escdescription?>",
should be sufficient (line 80).

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: ld-json and double quote in product descriptions
« Reply #1 on: December 03, 2019, 17:28:15 pm »
or maybe directly an htmlspecialchars?

I see in the code before
Code: [Select]
if (empty($description)){
if (!empty($product->product_s_desc)){
$description = htmlspecialchars(strip_tags($product->product_s_desc));
} else {
$description = htmlspecialchars(strip_tags($product->product_desc));
}
}
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

diri

  • Jr. Member
  • **
  • Posts: 107
  • VirtueMart Version: most recent dev version (trunk)
Re: ld-json and double quote in product descriptions
« Reply #2 on: December 04, 2019, 06:22:12 am »
I've seen this code as well and used the extra variable to not to "disturb" any other functionality or overwrite because it's a problem with LD-JSON only in some cases (eg product  wheel size like 2" or height 19" in description).

AFAIR it's no problem when using TinyMCE or JCE but, using them can cause other problems especially when there is an update after you tweaked them a bit. Some automatic behaviour of those editors look comfortable, but ... .

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: ld-json and double quote in product descriptions
« Reply #3 on: December 11, 2019, 11:14:55 am »
how works this for you?

Code: [Select]
if (empty($description)){
if (!empty($product->product_s_desc)){
$description = $product->product_s_desc;
} else {
$description = $product->product_desc;
}
}
$description = str_replace('"','\"',htmlspecialchars(strip_tags($description)));
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4341
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: ld-json and double quote in product descriptions
« Reply #4 on: December 11, 2019, 12:13:20 pm »
About this problem,
why you dont use an Object and PHP json_encode function?
This is 100% safe