Skip to content

Fix filename extension stripping bug and clean up dev tooling#28

Closed
f2cmb wants to merge 2 commits intoBeAPI:masterfrom
f2cmb:fix/review-issues
Closed

Fix filename extension stripping bug and clean up dev tooling#28
f2cmb wants to merge 2 commits intoBeAPI:masterfrom
f2cmb:fix/review-issues

Conversation

@f2cmb
Copy link
Copy Markdown

@f2cmb f2cmb commented Apr 3, 2026

Summary

The main fix: str_replace($ext, '', $file_name) stripped every occurrence of the extension string from the filename, not just the suffix. Example: css.style.css became style instead of css.style. Fixed with pathinfo() + substr().

Since I was in there anyway, I cleaned up a few things that were bugging me:

  • PHPCompatibility testVersion was set to 5.6- but the plugin requires PHP 8.0+. Updated to 8.0-.
  • Removed the convert*ToExceptions attributes from PHPUnit config (deprecated in 9.5, gone in 10).
  • Fixed typos in comments ("chats" → "chars", "caracters" → "characters") and renamed test_convert_at_sign_to_dashes to test_remove_at_sign, since the @ is stripped, not converted to a dash.

Note

High Risk
Changes core upload filename sanitization and updates the special-character lists; the latter introduces non-standard quote characters that could cause parsing/runtime issues if not intentional. Also updates PHP compatibility/testing configs, which may affect CI outcomes.

Overview
Fixes a filename extension handling bug in bea_sanitize_file_name() by switching from regex/str_replace() to pathinfo() + substr() so only the trailing extension is removed and then re-appended.

Updates the set of characters escaped by bea_sanitize_file_name_chars() and cleans up related comments, but also changes the quoting of these literals (now using typographic quotes), which may alter behavior or even break parsing if unintended.

Modernizes dev tooling by bumping PHPCompatibility to 8.0- in phpcs.xml, removing deprecated PHPUnit convert*ToExceptions flags, and renaming a unit test to reflect that @ is removed rather than converted.

Written by Cursor Bugbot for commit 59b8e05. This will update automatically on new commits. Configure here.

@f2cmb f2cmb closed this Apr 3, 2026
@f2cmb f2cmb reopened this Apr 3, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread bea-sanitize-filename.php Outdated
Comment thread bea-sanitize-filename.php
Comment thread bea-sanitize-filename.php
@f2cmb f2cmb requested a review from herewithme April 3, 2026 19:08
@herewithme
Copy link
Copy Markdown
Member

Merci pour le report de bugs, j'ai repris la prop ici : #29

@herewithme herewithme closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants