-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[url_launcher] Decode file URLs before passing it to ShellExecuteW #7774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
cf02161
to
d5d8423
Compare
Thanks for the contribution! Since the checklist isn't complete, I'm assuming this is a work in progress, and marking as a Draft accordingly. Once you've completed all of the steps, please mark it as ready for review. It also appears that this PR assumes that |
a60971f
to
abd0f7b
Compare
- ShellExecuteW does not handle file: urls that contain %-encoded UTF-8 strings correctly. %-encoded ASCII strings are handled correctly, as are file "urls" that contain Unicode strings in its path component. - This change perform URL decode on file: urls before passing to ShellExecuteW.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @cbracken for secondary review.
(Longer term we may need to revisit this logic; it's not at all clear that we are using open
correctly current even though it mostly seems to work. The docs say "The item can be a file or folder", and even with this change we are passing a file URL rather than path, which may not be right. And it's not clear whether open
is supposed to even work at all for other kinds of URLs, even though it apparently does.)
My guess would be that file: is being handled by ShellExecute as a file moniker (which happens to have a similar syntax, but without URL encoding). That might also explain starting the image editor instead of a browser when passed an image file. It would be a somewhat unfortunate change in behavior if this were to be changed to pass all URLs to the browser. |
That's definitely an anti-goal. What we want is for the OS to determine the best handler for any given URL and pass it to that; that's explicitly what the underlying APIs used by all the other platform implementations of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flutter/packages@5582669...2a1c477 2024-10-18 [email protected] [camera_android] Convert Dart to native calls to use Pigeon (flutter/packages#7874) 2024-10-17 [email protected] [url_launcher] Decode file URLs before passing it to ShellExecuteW (flutter/packages#7774) 2024-10-17 [email protected] [in_app_purchase_storekit] Add support for purchase and transactions (flutter/packages#7887) 2024-10-17 [email protected] [interactive_media_ads] Adds internal wrapper for iOS native `IMACompanionAd` (flutter/packages#7873) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
strings are handled correctly, as are file "urls" that contain Unicode strings in its path component.
Fixes flutter/flutter#156790
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.