Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
electron
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
ExcellentOSS
electron
Commits
c8ba3b45
Unverified
Commit
c8ba3b45
authored
3 years ago
by
Charles Kerr
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: in GTK open dialog, do not preview huge files (#31799)
parent
a6a5ca1d
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shell/browser/ui/file_dialog_gtk.cc
+16
-4
16 additions, 4 deletions
shell/browser/ui/file_dialog_gtk.cc
with
16 additions
and
4 deletions
shell/browser/ui/file_dialog_gtk.cc
+
16
−
4
View file @
c8ba3b45
...
...
@@ -369,6 +369,20 @@ void FileChooserDialog::AddFilters(const Filters& filters) {
}
}
bool
CanPreview
(
const
struct
stat
&
st
)
{
// Only preview regular files; pipes may hang.
// See https://crbug.com/534754.
if
(
!
S_ISREG
(
st
.
st_mode
))
{
return
false
;
}
// Don't preview huge files; they may crash.
// https://github.com/electron/electron/issues/31630
// Setting an arbitrary filesize max t at 100 MB here.
constexpr
off_t
ArbitraryMax
=
100000000ULL
;
return
st
.
st_size
<
ArbitraryMax
;
}
void
FileChooserDialog
::
OnUpdatePreview
(
GtkFileChooser
*
chooser
)
{
CHECK
(
!*
supports_gtk_file_chooser_native
);
gchar
*
filename
=
gtk_file_chooser_get_preview_filename
(
chooser
);
...
...
@@ -377,10 +391,8 @@ void FileChooserDialog::OnUpdatePreview(GtkFileChooser* chooser) {
return
;
}
// Don't attempt to open anything which isn't a regular file. If a named
// pipe, this may hang. See https://crbug.com/534754.
struct
stat
stat_buf
;
if
(
stat
(
filename
,
&
stat_buf
)
!=
0
||
!
S_ISREG
(
stat_buf
.
st_mode
))
{
struct
stat
sb
;
if
(
stat
(
filename
,
&
sb
)
!=
0
||
!
CanPreview
(
sb
))
{
g_free
(
filename
);
gtk_file_chooser_set_preview_widget_active
(
chooser
,
FALSE
);
return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment