mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
Userland: Filter out unsupported file types in open dialogs in more apps
This commit is contained in:
parent
27011cf55d
commit
8bd68198d6
10 changed files with 69 additions and 16 deletions
|
@ -92,15 +92,17 @@ ErrorOr<size_t> CertificateStoreModel::add(Vector<Certificate> const& certificat
|
|||
|
||||
ErrorOr<void> CertificateStoreWidget::import_pem()
|
||||
{
|
||||
auto fsac_result = FileSystemAccessClient::Client::the().open_file(window(), { .window_title = "Import"sv });
|
||||
FileSystemAccessClient::OpenFileOptions options {
|
||||
.window_title = "Import"sv,
|
||||
.allowed_file_types = Vector {
|
||||
GUI::FileTypeFilter { "Certificate Files", { { "pem", "crt" } } },
|
||||
},
|
||||
};
|
||||
auto fsac_result = FileSystemAccessClient::Client::the().open_file(window(), options);
|
||||
if (fsac_result.is_error())
|
||||
return {};
|
||||
|
||||
auto fsac_file = fsac_result.release_value();
|
||||
auto filename = fsac_file.filename();
|
||||
if (!(filename.ends_with_bytes(".pem"sv) || filename.ends_with_bytes(".crt"sv)))
|
||||
return Error::from_string_view("File is not a .pem or .crt file."sv);
|
||||
|
||||
auto data = TRY(fsac_file.release_stream()->read_until_eof());
|
||||
auto count = TRY(m_root_ca_model->add(TRY(DefaultRootCACertificates::parse_pem_root_certificate_authorities(data))));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue