CMS MADE SIMPLE FORGE

CGExtensions

 

[#6831] Quotes are removed from string in smart_explode

avatar
Created By: Leo Holsti (lholsti)
Date Submitted: Mon Aug 29 04:21:52 -0400 2011

Assigned To:
Version: 1.26.4
CMSMS Version: 1.9.2
Severity: Minor
Resolution: None
State: Open
Summary:
Quotes are removed from string in smart_explode
Detailed Description:
Encountered this problem while trying to import properties containg html-links
in frontendusers. I had textareas with normal links (<a href="....">...</a>) and
found that the quotes around the urls where being dropped by the smart_explode
function.

I tried to fix this by adding
  $col .= $str[$i];
to the case testing for $safe_char ( i.e. quotes). 

This leads to double quote-marks when importing csv-files, as quotes need to be
preceded by a quote (""). This code seems to fix the problem:

          case $safe_char:
            if( $prev_char != '\\' )
              {
                $is_safe = !$is_safe;
              }
            if( $prev_char != '"' )
              {
                $col .= $str[$i];
              }
            break;

It works while importing csv-files in FEU and has not been tested elsewhere. I
am worried about how it works with strings where quotes are escaped with
backslash, instead of another quote.

Please do not use this fix in a production-environment. It is untested and can
probably result in unpredicted problems.


History