Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[5.x]: Renaming an asset without the file extension fails with “” is not an allowed file extension.

Đang mở
#19,950 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

Start at the asset edit flow that saves the Filename field and trace how it validates extensions, especially names with no extension or a dot in the base name. Add or locate tests for renaming Test.pdf to Test-Renamed and Test-Schedule-v1.2; done means the original extension is retained or the validation error clearly reports a missing or disallowed extension.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug repo:cms
What happened?

On the asset edit page, the Filename field contains the full filename, including the extension (e.g. Activities-Schedule.pdf). When editors rename a file, they often type just the new name and leave out the extension, since that's what they'd expect to edit.

Craft then rejects the save, and the error shows an empty extension: “” is not an allowed file extension. The Filename field also goes back to the original name, so it isn't clear to editors what went wrong or how to fix it. Our content editors have reported this as a bug.

The same thing happens when the new name contains a dot, such as a version number (Schedule-v1.2). Craft reads 2 as the extension and rejects it.

It would help if Craft kept the original extension when the new filename has none, or showed the extension as a fixed suffix outside the editable part of the field.

Steps to reproduce

  1. Upload a PDF to any asset volume, e.g. Test.pdf.
  2. Open the asset's edit page in the Control Panel.
  3. In the Filename field, replace the whole value with Test-Renamed (no extension).
  4. Click Save.

Expected behavior

The asset is renamed to Test-Renamed.pdf, keeping the original extension. Or, at minimum, the error says that the file extension is missing.

Actual behavior

The save fails with "Couldn’t save asset." and the field error “” is not an allowed file extension., and the Filename field goes back to Test.pdf.

Renaming to Test-Schedule-v1.2 fails the same way with “2” is not an allowed file extension.

Craft CMS version

5.11.3 (Pro)

PHP version

8.2.30

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions
Ngôn ngữ chính
PHP
Star
3.6k
Fork
706
Merge trung bình
11 giờ 2 phút
Pull request đã merge (30 ngày)
252

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của craftcms/cms

Tất cả issue của craftcms/cms

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.