Fix a crash when initialDirectory contains special characters on Linux#1963
Open
TechnicJelle wants to merge 1 commit intomiguelpruivo:masterfrom
Open
Fix a crash when initialDirectory contains special characters on Linux#1963TechnicJelle wants to merge 1 commit intomiguelpruivo:masterfrom
TechnicJelle wants to merge 1 commit intomiguelpruivo:masterfrom
Conversation
This prevents the file_picker from crashing when initialDirectory contains any special characters
Author
|
I forked this from the tag |
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.
Today, I was testing my Flutter program, and happened to select a directory that has a non-ASCII character in it.
Specifically, this character: گ (Arabic letter Kaf with line, used for /g/)
The selecting part went okay, and I got the result back just fine.
However, my application stores the resulting path, and uses that as the
initialDirectoryfor the next pick.There, it would keep crashing:
Stacktrace
The exact code it was crashing on was this:
In that last line is an assert that ensures the
ints of thetmplist are actually bytes, and not way too high.However, that special character results in the value being

1711, as you can see in this screenshot of the debugger:The full contents of the tmp list
And so, together with a friend, we concluded that the way that the
tmplist is being constructed isn't completely proper.This PR fixes that, by using Dart's built-in UTF-8 encoder to convert the string to a byte array.
I verified with the DBus docs, and DBus String are indeed only allowed to be UTF-8:
I have tested this in my own program, and it does solve the issue.
Here's a pair of (somewhat crappy) videos demonstrating the issue and that the fix works:
The issue:
Peek.2026-03-10.21-41.mp4
The fix:
Peek.2026-03-10.21-35.mp4