Problem/Motivation
When exporting spreadsheet data (XLS/XLSX) with Strip HTML enabled, cell text is truncated if the content contains plain-text < / > characters (for example low pressure, &lt;1 MPa).
In Xls::formatValue() (src/Encoder/Xls.php) the operations run in this order:
Html::decodeEntities($value)— e.g.&lt;1 MPabecomes<1 MPastrip_tags($value)— PHP treats<...as an HTML tag and removes or truncates the remainder of the string
This also affects Views Data Export when the display format is XLS/XLSX and strip-tags behaviour is active (including the encoder default when xls_settings are not passed from the data export style plugin).
Steps to reproduce
- Drupal 10.x,
xls_serialization2.1.0,views_data_export. - Create content with a formatted text field containing HTML markup and text such as
Buffer hydrogen gas holder: low pressure, &lt;1 MPa. - Create a View with a Data export display, format XLS or XLSX, with strip-tags behaviour enabled (XLS settings and/or encoder defaults).
- Export and open the spreadsheet.
Expected: HTML tags removed; plain < and > preserved in the cell.
Actual: Text after < is removed or truncated (e.g. export ends at low pressure,).
Proposed resolution
Swap the order in formatValue() so tags are stripped before entities are decoded:
if ($this->stripTags) { $value = strip_tags($value); $value = Html::decodeEntities($value); }
Real HTML tags are removed first; encoded plain-text symbols are decoded afterwards and remain in the export.
| Comment | File | Size | Author |
|---|---|---|---|
| xls_serialization-fix-strip-tags-truncation.patch | 380 bytes | gtriant |
Issue fork xls_serialization-3591045
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
mably commentedThanks @gtriant for your patch.
Can you confirm that this issue's MR fixes your problem?
Comment #5
gtriant commentedYes, it does
Comment #7
mably commented