Skip to content

Add UTF-16 BOM support for Vaadin file uploads#261

Merged
fabieu merged 7 commits intomainfrom
copilot/support-utf16-bom-upload
Nov 6, 2025
Merged

Add UTF-16 BOM support for Vaadin file uploads#261
fabieu merged 7 commits intomainfrom
copilot/support-utf16-bom-upload

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Some data providers encode files in UTF-16 with BOM rather than UTF-8, causing upload failures when parsing JSON data.

Changes

  • New EncodingUtils utility: Detects and handles UTF-8, UTF-16LE, UTF-16BE with or without BOM

    • BOM detection at byte level (FF FE, FE FF, EF BB BF)
    • Heuristic fallback for UTF-16 without BOM (null byte pattern analysis)
    • Automatic BOM removal and control character cleanup
  • Updated upload handlers: Replace new String(data) with EncodingUtils.bytesToString(data)

    • BopEditorView, BopManagementView, EntrylistEditorView
    • 5 upload handlers total (entrylist, BoP files, session results, custom cars)

Example

// Before
AccBop accBop = JsonClient.fromJson(new String(data), AccBop.class);

// After
String content = EncodingUtils.bytesToString(data);
AccBop accBop = JsonClient.fromJson(content, AccBop.class);

The utility defaults to UTF-8 when no BOM is present, maintaining backward compatibility. Test coverage includes all encoding combinations with and without BOMs.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support UTF-16 BOM for file uploads since some providers do not use common UTF-8 encoding</issue_title>
<issue_description>Add support for UTF16 with BOM to all Vaadin File Uploads. Keep the business logic identical, just parse the input data differently.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 5, 2025 23:48
Co-authored-by: fabieu <43068791+fabieu@users.noreply.github.com>
Co-authored-by: fabieu <43068791+fabieu@users.noreply.github.com>
Co-authored-by: fabieu <43068791+fabieu@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for UTF-16 BOM in file uploads Add UTF-16 BOM support for Vaadin file uploads Nov 5, 2025
Copilot AI requested a review from fabieu November 5, 2025 23:58
- Changed detection algorithm in EncodingUtils
- Update package for EncodingUtils
@fabieu fabieu marked this pull request as ready for review November 6, 2025 18:07
@fabieu fabieu merged commit 5fc6afe into main Nov 6, 2025
1 check passed
@fabieu fabieu deleted the copilot/support-utf16-bom-upload branch November 6, 2025 18:09
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.

Support UTF-16 BOM for file uploads since some providers do not use common UTF-8 encoding

2 participants