In the theme_views_bonus_export_csv() function, each visible field is run through a number of filters (replacing " with "", decoding HTML entities, etc). However, the " substitution is run before the decode_entities() call, which means any """ entities will be returned as " instead of "". This has horrible horrible repercussions. I propose moving the decode_entities() call to somewhere before the str_replace().

The same process has another strips out line breaks and commas; the purpose of encapsulating fields in quote marks is to allow fields to contain these characters, so I would advocate removing this call entirely. Also the $value = $field assignment appears to have no purpose as the $value function is immediately reassigned to the result of the views_theme_field() call.

This would leave the foreach field loop as follows:

    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] !== false) {
        $value = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
        $value = preg_replace('/<.*?>/', '', $value); // strip html tags
        $value = decode_entities($value); // decode html entities eg '&quot;'
        $value = str_replace('"', '""', $value); // escape " characters
        $values[] = '"' . $value . '"';
      }
    }

Incidentally, I would be interested to know why the generic preg_replace() function is used in preference to strip_tags().

Comments

dmitrig01’s picture

Status: Active » Fixed

Committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.