Skip to content

Form validation fails when uploading images due to line break encoding differences #2574

@Sendouc

Description

@Sendouc

Problem

When creating/editing a calendar event, validation fails with description length exceeding 3000 characters when an image is uploaded, even though the same description passes validation without an image upload.

Example:

  • Without image upload: description length = 2976 ✅
  • With image upload: description length = 3022 ❌ (exceeds 3000 limit)
  • Difference: 46 characters

Discovered when attempting to edit: https://sendou.ink/to/2301

Root Cause

The issue occurs in uploadImageIfSubmitted (app/utils/remix.server.ts:303-339):

  • With image: Uses parseMultipartFormData(request, uploadHandler) which converts line breaks from \n (1 byte) to \r\n (2 bytes) per multipart/form-data encoding spec
  • Without image: Uses request.formData() which preserves \n line breaks

If the description has 46 line breaks, each becomes 2 characters instead of 1, adding exactly 46 characters to the length.

Discord helpdesk post

https://discord.com/channels/299182152161951744/1426964946553667704/1426964946553667704

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions