Sanitize worksheet title

Created on 23 September 2021, almost 3 years ago
Updated 29 May 2023, about 1 year ago

This is a follow-up ticket to #2903479: Sanitize worksheet title β†’ which seems to have broken at some point, since we're having the same issue with ':' characters in titles, see error:

Drupal\Component\Serialization\Exception\InvalidDataTypeException: Invalid character found in sheet title in Drupal\xls_serialization\Encoder\Xls->encode() (line 146 of /vagrant/www/modules/contrib/xls_serialization/src/Encoder/Xls.php).

With complete stacktrace error upon export:

Drupal\Component\Serialization\Exception\InvalidDataTypeException: Invalid character found in sheet title in Drupal\xls_serialization\Encoder\Xls->encode() (line 146 of modules/contrib/xls_serialization/src/Encoder/Xls.php). PhpOffice\PhpSpreadsheet\Worksheet\Worksheet->setTitle('Test Reports: All orders') (Line: 97)
Drupal\xls_serialization\Encoder\Xls->encode(Array, 'xlsx', Array) (Line: 40)
Symfony\Component\Serializer\Encoder\ChainEncoder->encode(Array, 'xlsx', Array) (Line: 276)
Symfony\Component\Serializer\Serializer->encode(Array, 'xlsx', Array) (Line: 119)
Symfony\Component\Serializer\Serializer->serialize(Array, 'xlsx', Array) (Line: 342)
Drupal\views_data_export\Plugin\views\style\DataExport->render() (Line: 450)
Drupal\rest\Plugin\views\display\RestExport->Drupal\rest\Plugin\views\display\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 451)
Drupal\rest\Plugin\views\display\RestExport->render() (Line: 1533)
Drupal\views\ViewExecutable->render() (Line: 793)
Drupal\views_data_export\Plugin\views\display\DataExport::processBatch('vde_reports_all_orders', 'data_export_1', Array, Array, 53, Array, '/vde-reports-all-orders?completed%5Bmin%5D=02/02/2021&completed%5Bmax%5D=02/17/2021&label=', Array) (Line: 295)
_batch_process() (Line: 137)
_batch_do() (Line: 93)
_batch_page(Object) (Line: 55)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

It would seem the function validateWorksheetTitle doesn't properly replace the problematic characters.

Maybe the issue could come from the regex: '[:\\*/\[\]?]' which would seem to be missing something.

To test the issue try exporting a views page with the slash '/' characters in its title, for example, or ':' (colon).

Thanks in advance.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡«πŸ‡·France DYdave

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024