Skip to content

Fix UTF double encoding in file editor - #2199

Merged
lancepioch merged 3 commits into
mainfrom
lance/2187
Feb 14, 2026
Merged

Fix UTF double encoding in file editor#2199
lancepioch merged 3 commits into
mainfrom
lance/2187

Conversation

@lancepioch

Copy link
Copy Markdown
Member

Fixes #2187

@lancepioch lancepioch self-assigned this Feb 8, 2026
@coderabbitai

coderabbitai Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR standardizes character encoding handling across file content operations by implementing strict UTF-8 validation in the editor, specifying UTF-8 charset in HTTP response headers for file content retrieval, and adding content-type headers to daemon file write requests.

Changes

Cohort / File(s) Summary
Editor Content Retrieval
app/Filament/Server/Resources/Files/Pages/EditFiles.php
Replaced multi-encoding fallback (UTF-8, UTF-16, ISO-8859-1, ASCII) with strict UTF-8 validation, falling back only to ISO-8859-1 conversion if needed.
File Content API Response
app/Http/Controllers/Api/Client/Servers/FileController.php
Added UTF-8 charset specification to Content-Type response header (text/plain; charset=utf-8) for file content endpoint.
Daemon File Write Request
app/Repositories/Daemon/DaemonFileRepository.php
Added Content-Type: text/plain header specification when sending file contents to daemon in PUT requests.

Possibly related PRs

  • #1896: Previously modified the same editor content retrieval to add multi-encoding fallback; this PR refines that approach with stricter UTF-8 validation and narrower encoding fallback options.
🚥 Pre-merge checks | ✅ 2 | ❌ 4
❌ Failed checks (4 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Fix UTF double encoding in file editor' is unrelated to the linked issue #2187 about small caps not rendering in MonacoEditor. Update the title to reflect the actual issue being fixed, such as 'Fix small caps rendering in MonacoEditor' or change the implementation to address the stated problem.
Linked Issues check ⚠️ Warning The PR implements UTF-8 encoding fixes, but issue #2187 specifically reports small caps unicode characters not rendering in MonacoEditor. The changes address encoding rather than the reported rendering problem. Clarify whether UTF-8 encoding fixes resolve the small caps rendering issue, or implement additional changes to address Monaco font/display capabilities for small caps characters.
Out of Scope Changes check ⚠️ Warning The PR modifies file encoding handling (UTF-8 validation and ISO-8859-1 conversion) which is not explicitly mentioned in issue #2187's requirements for fixing small caps display. Either document how UTF-8 encoding fixes resolve small caps rendering, or revert changes unrelated to the Monaco editor display issue and implement font/display-specific fixes.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (33 files):

⚔️ .github/workflows/ci.yaml (content)
⚔️ Dockerfile (content)
⚔️ Dockerfile.dev (content)
⚔️ app/Filament/Admin/Pages/Settings.php (content)
⚔️ app/Filament/Admin/Resources/DatabaseHosts/Pages/CreateDatabaseHost.php (content)
⚔️ app/Filament/Admin/Resources/Eggs/Pages/EditEgg.php (content)
⚔️ app/Filament/Admin/Resources/Nodes/Pages/ListNodes.php (content)
⚔️ app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php (content)
⚔️ app/Filament/Admin/Resources/Servers/Pages/CreateServer.php (content)
⚔️ app/Filament/Admin/Resources/Servers/Pages/EditServer.php (content)
⚔️ app/Filament/Admin/Resources/Servers/RelationManagers/AllocationsRelationManager.php (content)
⚔️ app/Filament/Admin/Resources/Users/UserResource.php (content)
⚔️ app/Filament/Pages/Auth/Login.php (content)
⚔️ app/Filament/Server/Resources/Backups/BackupResource.php (content)
⚔️ app/Filament/Server/Resources/Files/Pages/EditFiles.php (content)
⚔️ app/Filament/Server/Resources/Schedules/Pages/CreateSchedule.php (content)
⚔️ app/Filament/Server/Resources/Subusers/SubuserResource.php (content)
⚔️ app/Http/Controllers/Api/Client/Servers/FileController.php (content)
⚔️ app/Jobs/ProcessWebhook.php (content)
⚔️ app/Models/Node.php (content)
⚔️ app/Models/Plugin.php (content)
⚔️ app/Providers/Filament/PanelProvider.php (content)
⚔️ app/Repositories/Daemon/DaemonFileRepository.php (content)
⚔️ app/Services/Eggs/EggConfigurationService.php (content)
⚔️ app/Services/Eggs/Sharing/EggImporterService.php (content)
⚔️ app/Services/Helpers/PluginService.php (content)
⚔️ app/Services/Servers/GetUserPermissionsService.php (content)
⚔️ app/Transformers/Api/Application/EggTransformer.php (content)
⚔️ composer.json (content)
⚔️ composer.lock (content)
⚔️ lang/en/admin/node.php (content)
⚔️ resources/views/filament/server/pages/list-files.blade.php (content)
⚔️ tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description correctly references the linked issue #2187, establishing a clear connection to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lancepioch lancepioch changed the title Add fallback fonts for unicode Fix UTF double encoding in file editor Feb 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/Http/Controllers/Api/Client/Servers/FileController.php (1)

69-81: ⚠️ Potential issue | 🟡 Minor

Response declares UTF-8 but content is not validated/converted.

EditFiles.php validates and converts content to UTF-8 (Lines 152-156), but this API endpoint serves raw daemon output with a charset=utf-8 header. If the file contains non-UTF-8 bytes, the header will be a lie, potentially causing client-side decoding errors.

Consider applying the same encoding logic here:

         $response = $this->fileRepository->setServer($server)->getContent(
             $request->get('file'),
             config('panel.files.max_edit_size')
         );
 
+        if (!mb_check_encoding($response, 'UTF-8')) {
+            $response = mb_convert_encoding($response, 'UTF-8', 'ISO-8859-1');
+        }
+
         Activity::event('server:file.read')
             ->property('file', $request->get('file'))
             ->log();
🧹 Nitpick comments (1)
app/Repositories/Daemon/DaemonFileRepository.php (1)

56-56: Consider specifying charset in the Content-Type header for consistency.

The API response in FileController.php uses text/plain; charset=utf-8, but the outgoing request here only sets text/plain. For end-to-end consistency in encoding signaling, consider text/plain; charset=utf-8.

-            ->withBody($content, 'text/plain')
+            ->withBody($content, 'text/plain; charset=utf-8')

@lancepioch
lancepioch merged commit 44f6cf8 into main Feb 14, 2026
17 checks passed
@lancepioch
lancepioch deleted the lance/2187 branch February 14, 2026 15:33
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Small caps not working on MonacoEditor

1 participant