trypost/app/Models
Paulo Castellano 74e6d341ab
fix: sanitize invalid UTF-8 bytes in uploaded filenames (#265)
* fix: sanitize invalid UTF-8 bytes in uploaded filenames

A client-supplied filename containing a raw non-UTF-8 byte (e.g. 0x97,
a Windows-1252 em dash) crashed the media insert with an uncaught
QueryException: Postgres rejects invalid UTF-8 byte sequences outright
under UTF8 encoding. Centralized a sanitizeOriginalFilename() helper
in HasMedia and applied it to all three insert paths that store
original_filename: addMedia(), addMediaFromPath(), and
addMediaFromStoredPath() (the multipart cloud-upload registration
path) — so every upload entry point is covered, not just the one that
happened to crash in production.

Fixes Nightwatch issue #24.

* refactor: use mb_scrub() instead of the mb_convert_encoding same-encoding trick

mb_scrub() (PHP 8.1+) is the purpose-built function for scrubbing
invalid byte sequences — same behavior, clearer intent than the
convert-to-same-encoding workaround it replaces.

* test: cover addMediaFromStoredPath (previously untested, including sanitize fix)

addMediaFromStoredPath — the multipart cloud-upload registration path
— had zero test coverage before this PR, including for the invalid
UTF-8 filename fix applied to it. Added a basic happy-path test plus
the sanitize regression test, matching the coverage already added for
addMedia() and addMediaFromPath().

Verified the regression test actually catches the bug: reverted the
sanitize call for this one method locally, confirmed the test fails
with the exact Nightwatch #24 QueryException, then restored the fix.
2026-08-09 14:29:29 -03:00
..
Traits fix: sanitize invalid UTF-8 bytes in uploaded filenames (#265) 2026-08-09 14:29:29 -03:00
AccessToken.php Activation checklist + MCP OAuth authorize UX (#239) (#250) 2026-08-07 20:34:43 -03:00
Account.php Activation checklist + MCP OAuth authorize UX (#239) (#250) 2026-08-07 20:34:43 -03:00
AiUsageLog.php feat: per-workspace pricing, onboarding, and billing overhaul 2026-06-21 20:40:03 -03:00
Automation.php Denormalize automation trigger_type into an indexed column 2026-06-13 15:26:54 -03:00
AutomationNodeRun.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
AutomationNodeState.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
AutomationRun.php Tidy automation backend: run duration, folded migrations, imports 2026-06-13 16:30:32 -03:00
AutomationTriggerItem.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
Invite.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
Media.php refactor(media): centralize image/video/document detection in Media\Type 2026-06-25 10:57:57 -03:00
Notification.php feat: notification system with SendNotification job, dialog UI, tests 2026-03-30 16:47:03 -03:00
NotificationPreference.php feat: proactive connection check for at-risk posts + SocialAccount name centralization (#256) 2026-08-09 11:10:39 -03:00
Plan.php feat: per-workspace pricing, onboarding, and billing overhaul 2026-06-21 20:40:03 -03:00
Post.php feat: proactive connection check for at-risk posts + SocialAccount name centralization (#256) 2026-08-09 11:10:39 -03:00
PostComment.php feat: add post_comments table, model, and factory 2026-04-15 20:08:16 -03:00
PostPlatform.php feat: proactive connection check for at-risk posts + SocialAccount name centralization (#256) 2026-08-09 11:10:39 -03:00
SocialAccount.php feat: proactive connection check for at-risk posts + SocialAccount name centralization (#256) 2026-08-09 11:10:39 -03:00
Subscription.php feat: Implement soft deletes for workspace hashtags and labels, and integrate content_type into the initial post platforms table creation. 2026-01-17 14:44:37 -03:00
SubscriptionItem.php feat: Implement soft deletes for workspace hashtags and labels, and integrate content_type into the initial post platforms table creation. 2026-01-17 14:44:37 -03:00
User.php feat: proactive connection check for at-risk posts + SocialAccount name centralization (#256) 2026-08-09 11:10:39 -03:00
Workspace.php Structure brand voice and make generated copy platform-aware 2026-06-12 17:09:39 -03:00
WorkspaceInvite.php refactor: restructure to Actions, subdomain routes (app/api), API tokens 2026-03-29 19:24:28 -03:00
WorkspaceLabel.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
WorkspaceSignature.php chore: remove deprecated localization files 2026-05-03 15:23:25 -03:00