Prevent \uXXXX escape leakage on paste and enforce UTF-8 song file persistence - #52
Merged
Merged
Conversation
Copilot created this pull request from a session on behalf of
reckel-jm
May 31, 2026 18:04
View session
reckel-jm
marked this pull request as ready for review
June 6, 2026 12:59
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent pasted \uXXXX escape sequences from being persisted literally in the song editor, and to make song/text persistence consistently use explicit UTF-8 encoding across editor and helper flows.
Changes:
- Added a paste-time decoder that converts
\uXXXX(including surrogate pairs) into actual Unicode characters. - Switched editor load/save (and copy flow) to explicit
TEncoding.UTF8. - Updated song export and generic text file helpers to read/write with
TEncoding.UTF8.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/generics/textfilehandler.pas | Uses explicit UTF-8 for generic text load/save. |
| src/generics/lyrics.pas | Exports song files explicitly as UTF-8. |
| src/frames/editordisplaysongcontent.pas | Adds \uXXXX paste decoding; editor load/save now explicit UTF-8. |
| src/forms/songeditor.pas | Copy-to-new-song write now explicit UTF-8. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
490
to
+493
| try | ||
| outputcontent := TStringList.Create; | ||
| outputcontent.Text := self.ExportAsSongFile; | ||
| outputcontent.SaveToFile(outputfilename); | ||
| outputcontent.SaveToFile(outputfilename, TEncoding.UTF8); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pasting into the song editor could persist non-ASCII text as escaped Unicode literals (e.g.
\u4F60\u597D) instead of real characters. This change ensures pasted content is materialized as Unicode text and song files are consistently read/written as UTF-8.Editor paste decoding
\uXXXXsequences during paste handling inTfrmDisplaySongContent.\uD800..\uDBFF+\uDC00..\uDFFF) and leaves invalid surrogate input unchanged.Explicit UTF-8 file I/O in editor flows
TEncoding.UTF8ineditordisplaysongcontent.pas.songeditor.pas.UTF-8 consistency in song/text persistence helpers
lyrics.pasto write UTF-8 explicitly.textfilehandler.pasto load/save with UTF-8.