The xls encoder doesn't strip tags when no setting is provided.

Created on 3 December 2024, 19 days ago

Problem/Motivation

The issue #3108301 has caused a regression for me.
When using a views data export (so the 'data export' style, not the excel export style), and combining that with the format "xlsx" (using the XlsxEncoder from this module), values aren't trimmed or stripped of html tags.
This happens because the last 2 settings below aren't provided with any values (so also no default values).

// src/Encoder/Xls.php Lines#386-399
protected function setSettings(array $settings) {
  // Temporary fix this until it would be fixed at the views_data_export.
  if (isset($settings['xls_format'])) {
    if ($settings['xls_format'] == XlsSerializationConstants::EXCEL_2007_FORMAT) {
      $settings['xls_format'] = 'Xlsx';
    }
    if ($settings['xls_format'] == XlsSerializationConstants::EXCEL_5_FORMAT) {
      $settings['xls_format'] = 'Xls';
    }
    $this->xlsFormat = $settings['xls_format'];
  }
  $this->stripTags = $settings['strip_tags'];    // <----
  $this->trimValues = $settings['trim'];           // <----
}

Steps to reproduce

  • Create a data export display (NOT excel export)
  • Select .xls(x) as your request format
  • Add some fields
  • Result: some fields will be formatted as HTML, not stripped from their tags

Proposed resolution

Perhaps we should provide default values to these settings, to preserve the functionality prior to #3108301?

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium RandalV

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024