Skip to content

Commit

Permalink
Merge pull request zencart#6755 from scottcwilson/null_description
Browse files Browse the repository at this point in the history
Tweaks to handle null product descriptions
  • Loading branch information
drbyte authored Sep 18, 2024
2 parents 895636b + 5f58807 commit 0c52189
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion includes/functions/functions_strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function zen_clean_html($clean_it, $extraTags = '')
if (!is_array($extraTags)) $extraTags = [$extraTags];

// remove any embedded javascript
$clean_it = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $clean_it);
$clean_it = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $clean_it ?? '');

$clean_it = preg_replace('/\r/', ' ', $clean_it);
$clean_it = preg_replace('/\t/', ' ', $clean_it);
Expand Down
3 changes: 2 additions & 1 deletion includes/modules/pages/product_info/main_template_vars.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
$products_name = $product_info->fields['lang'][$_SESSION['languages_code']]['products_name'];
$products_model = $product_info->fields['products_model'];
// if no common markup tags in description, add line breaks for readability:
$products_description = (!preg_match('/(<br|<p|<div|<dd|<li|<span)/i', $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) ? nl2br($product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) : $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']);
$products_description = $product_info->fields['lang'][$_SESSION['languages_code']]['products_description'] ?? '';
$products_description = (!preg_match('/(<br|<p|<div|<dd|<li|<span)/i', $products_description) ? nl2br($products_description) : $products_description);

$products_image = (($product_not_found || $product_info->fields['products_image'] == '') && PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') ? PRODUCTS_IMAGE_NO_IMAGE : '';
if ($product_info->fields['products_image'] != '' || PRODUCTS_IMAGE_NO_IMAGE_STATUS != '1') {
Expand Down
2 changes: 1 addition & 1 deletion includes/modules/product_listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
$listing_product_name = zen_get_products_name((int)$record['products_id']);
$listing_description = '';
if ((int)PRODUCT_LIST_DESCRIPTION > 0) {
$listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'])), PRODUCT_LIST_DESCRIPTION);
$listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'] ?? '')), PRODUCT_LIST_DESCRIPTION);
}
$listing_model = $record['products_model'] ?? '';
$listing_mfg_name = $record['manufacturers_name'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion includes/modules/responsive_classic/product_listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
$listing_product_name = $record['products_name'] ?? '';
$listing_description = '';
if ((int)PRODUCT_LIST_DESCRIPTION > 0) {
$listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'])), PRODUCT_LIST_DESCRIPTION);
$listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'] ?? '')), PRODUCT_LIST_DESCRIPTION);
$lc_text .= '<div class="listingDescription">' . $listing_description . '</div>';
}
$listing_model = $record['products_model'] ?? '';
Expand Down

0 comments on commit 0c52189

Please sign in to comment.