Problem/Motivation

I have an image field configured to use File (Field) Paths and using token replacement for the file names. In the field settings I have enabled the File Name Options "Cleanup using pathauto" and "transliterate".

My Pathauto settings are configured to use a dash as a separator. Spaces are replaced by the separator and all punctuation is set to be removed.

However, when saving an image whose token-replaced name would include punctuation, the cleanup does not seem to happen. Specifically, I have a file name based on the node title, which contains the abbreviated word "Bros.".

When the image is uploaded, the file name is applied and most spaces are replaced with the separator character. However, the period is not removed and remains in the file name. Strangely, the space following the period is removed rather than being replaced like the rest of the spaces in the name.

I cannot say for sure, but I feel like I had tested for this scenario previously and did not experience this behavior. I have recently updated to the beta 4 release, and noticed in the release notes two issues that could be related to this new behavior:

- #1945148: Fixed issue with File path cleanup process.
- #1942720 by pp: Fixed issue with cleanup wehn token contains a '/'' character.

If it would help, I could probably downgrade back to beta 3 and test for this behavior in that previous release.

CommentFileSizeAuthor
#2 pathauto_periods-2047835-2.patch2.46 KBDeciphered
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered’s picture

Yup, this issue looks like it was introduced in commit 03ffeb0b4082b7ad0f45120cb4309be0d76db4e8, which was made in November 2011. The path is being split on periods ('.') and each part is processed then joined back together again... which clearly means that periods wouldn't be removed.

Obviously there has to be some part of this that still happens, because if you completely remove the period then you be left with a file with no extension.

Looking into this now.

Deciphered’s picture

Status: Active » Needs review
FileSize
2.46 KB

Checkout the attached patch, will likely be committed shortly.

I'm not entirely happy with the approach as it does custom logic if the path that is being sanitized is the last segment of the file name, but it does do the job, so it probably won't change.

Cheers,
Deciphered.

Deciphered’s picture

Status: Needs review » Fixed

Committed to 7.x-1.x

Status: Fixed » Closed (fixed)

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