Accented characters in filenames are not properly normalized since the 4.0.8 update

Created on 1 June 2023, over 1 year ago

Problem/Motivation

It seems that a code change involved in D10 compatibility fixes has caused a regression in the normalization of filenames when they contain accented characters.

Steps to reproduce

  1. Setup a website with Consumers and Image Styles so some derivatives may be generated by the module.
  2. Upload a file in a File Field in a Node Entity, with an accent, like a "é" in the filename.
  3. When trying to fetch the Node json:api ouptut, (with necessary parameters to get the derivatives in the output) the JSON Schema validation will fail and will throw a 500 error.

Proposed resolution

While inspecting the #3296867 commit, I noticed a line where the file_create_url function passed to Url::fromUri has not been precisely replaced by a compatible implementation :

By replacing
$this->fileUrlGenerator->generate($image_style->buildUrl($uri))

with
Url::fromUri($this->fileUrlGenerator->generateAbsoluteString($image_style->buildUrl($uri)))

The problem is gone.

Remaining tasks

  1. Submit a first patch.
  2. Writing Test for accented filenames?
  3. Review
  4. Commit
🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇫🇷France mattew

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

Comments & Activities

  • Issue created by @mattew
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    1 fail
  • @mattew opened merge request.
  • 🇫🇷France mattew

    I submitted a first MR. Can't figured out how to make tests works (very first assertion of the module test Class failed, derivatives are not in the "file--file" json:api response, I don't know why). So I didn't wrote a test for now, sorry.

  • 🇫🇷France Papa Ours Paris

    Thank you very much, it worked for me.

    When will this be included in a new release ?
    I have added it as a patch for the moment.

  • 🇧🇷Brazil barone Belo Horizonte

    This solves the issue I'm having with JSONAPI's following error:

    The website encountered an unexpected error. Please try again later.
    AssertionError: A JSON:API response failed validation (see the logs for details). Please report this in the issue queue on drupal.org in assert() (line 117 of core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php).
    assert(, 'A JSON:API response failed validation (see the logs for details). Please report this in the issue queue on drupal.org') (Line: 117)
    Drupal\jsonapi\EventSubscriber\ResourceResponseValidator->doValidateResponse(Object, Object) (Line: 108)
    Drupal\jsonapi\EventSubscriber\ResourceResponseValidator->onResponse(Object, 'kernel.response', Object)
    call_user_func(Array, Object, 'kernel.response', Object) (Line: 142)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.response') (Line: 202)
    Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 190)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    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: 49)
    Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 50)
    Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    However the stack here is updated to latest 9.x
    Drupal core: 9.5.11
    PHP: 8.1.23
    JSON API Extras: 8.x-3.24
    Consumers: 8.x-1.17
    Consumers Image Styles: 4.0.8

    I'm submitting a patch for now until this issue gets merged.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    1 fail
  • 🇧🇪Belgium stijndmd

    Did this issue get fixed in 4.0.10?

Production build 0.71.5 2024