Current code uses the following snippet to create the filename for the ICS file.

$filename = 'event-' . strtolower(Html::cleanCssIdentifier($field_settings['title'])) . '.ics';

Html::cleanCssIdentifier though doesn't transliterate the $field_settings['title'] value.

As a result, if the title contains unicode characters, the following exception is thrown: InvalidArgumentException: The filename fallback must only contain ASCII characters.

Comments

vensires created an issue. See original summary.

vensires’s picture

Issue summary: View changes
vensires’s picture

Status: Active » Needs review
StatusFileSize
new807 bytes
zekvyrin’s picture

Status: Needs review » Needs work

I'm ok with the change, but these need to come from dependency injection, not using Drupal:: global.

+    $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
+    $trans = \Drupal::transliteration();
vensires’s picture

Status: Needs work » Needs review
StatusFileSize
new3.68 KB

You 're right! Patch attached with some further cleanup.

vensires’s picture

Fixed a small bug in the previous patch.

zekvyrin’s picture

Why did you remove entityTypeManager?

It's used in line 107 (pre-patch)

    $field_config = $this->entityTypeManager->getStorage('field_config')->load($field_config_name);

I see currentUser wasn't used, so it can be removed, although I had the intention of adding it to tokens. But I guess this is a another todo.

zekvyrin’s picture

oh I see.. entityTypeManager() is a function in controllerBase. I need to test that (soon hopefully)

vensires’s picture

currentUser() is also provided by ControllerBase ;)

  • vensires authored add86df on 8.x-1.x
    Issue #3175373 by vensires: ASCII only characters expected in ICS file's...
zekvyrin’s picture

Status: Needs review » Fixed

Commited. Thank you @vensires

zekvyrin’s picture

Status: Fixed » Closed (fixed)

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