Hi,

currently a token replacement like [ffp-name-only-original].[ffp-extension-original] does not cover the case
of filenames ending with a dot but with no extension (e.g. file.).

In these cases the replacement ends up adding an extra dot at the end of the destination name giving file.. as result.

This is because the token regexes for the file names assume that there are always characters after the last dot when extracting the extension to subtract from the file name, I think this assumption can be relaxed.

I am going to send a patch which also covers some extra degenerate cases.

I tested the new regexes with these cases:

  • file
  • file.
  • file.ext
  • .ext

JFTR, I experienced the problem with files coming from a D6 site I am migrating to D8, in D6 uploading files with any extension was allowed.

Ciao,
Antonio

Command icon 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

ao2 created an issue. See original summary.

ao2’s picture

Status: Active » Needs review
StatusFileSize
new2.31 KB

Here is a tentative patch.

ao2’s picture

StatusFileSize
new534 bytes
new2.31 KB

Sending an updated patch as the previous one contained a typo which caused this warning:

preg_match(): Delimiter must not be alphanumeric or backslash filefield_paths.tokens.inc:65
voleger’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs MR

chandansha made their first commit to this issue’s fork.

chandansha’s picture

Status: Needs work » Needs review

Please Review the code and let me know if i missed anything.
Thanks!!

voleger’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll +Needs tests

We need to improve the token integration test with cases of uploaded files without extension.