Nom de fichier : Les espace sont remplacés par un +

Bonjour,

Je constate que quand je télécharge un fichier, le nom du fichier est modifié, les espaces sont remplacer par un + ou +‘_’+

fomr

Est-ce normal ?

Merci d’avance.
Abed.

Cela fait suite à la correction du filename envoyé dans le content-disposition du document.

Le nom du fichier est encodé en URL/RFC5987 sinon il peut poser des problèmes bloquants (si vous mettiez un caractère non ISO-8859-1, une virgule, point virgule… il ne se téléchargeait pas du tout suivant le navigateur).

C’est vrai que c’est dommage pour les espaces qui deviennent des “+”, on va essayer d’arranger ça.

Extrait W3C :

4.3. Disposition Parameter: ‘Filename’

The parameters “filename” and “filename*”, to be matched case- insensitively, provide information on how to construct a filename for storing the message payload. Depending on the disposition type, this information might be used right away (in the “save as…” interaction caused for the “attachment” disposition type), or later on (for instance, when the user decides to save the contents of the current page being displayed).

The parameters “filename” and “filename*” differ only in that “filename*” uses the encoding defined in [RFC5987], allowing the use of characters not present in the ISO-8859-1 character set ([ISO-8859-1]).

Many user agent implementations predating this specification do not understand the “filename*” parameter. Therefore, when both “filename” and “filename*” are present in a single header field value, recipients SHOULD pick “filename*” and ignore “filename”. This way, senders can avoid special-casing specific user agents by sending both the more expressive “filename*” parameter, and the “filename” parameter as fallback for legacy recipients (see Section 5 for an example).

En remplaçant les + par des %20 dans le filename envoyé ça fonctionne.

Testé avec un nom de fichier avec du chinois, l’euro, des espaces, un plus, une virgule… le nom proposé par chrome, edge et firefox est correct :

Ce sera poussé au prochain build, vous nous direz si ça fonctionne pour vos fichiers.

Merci @Francois , le pb est réglé.

1 Like