mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
PDFViewer: Prompt password for encrypted documents
This tackles a FIXME, but also makes sense to implement only now that the SecurityHandler logic has been fixed. When a Document is created an automatic attempt is made to provide the empty string as the password; even if this attempt failed the SecurityHandler still reported it had a user password, hence we never arrived to the VERIFY_NOT_REQUIRED line this commit is changing.
This commit is contained in:
parent
bb48a67f84
commit
89061883f2
Notes:
sideshowbarker
2024-07-17 02:59:43 +09:00
Author: https://github.com/rtobar Commit: https://github.com/SerenityOS/serenity/commit/89061883f2 Pull-request: https://github.com/SerenityOS/serenity/pull/16597
1 changed files with 10 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
|||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/FilePicker.h>
|
||||
#include <LibGUI/InputBox.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Menubar.h>
|
||||
|
@ -366,8 +367,15 @@ PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(Core::File& file)
|
|||
auto document = TRY(PDF::Document::create(m_buffer));
|
||||
|
||||
if (auto sh = document->security_handler(); sh && !sh->has_user_password()) {
|
||||
// FIXME: Prompt the user for a password
|
||||
VERIFY_NOT_REACHED();
|
||||
DeprecatedString password;
|
||||
while (true) {
|
||||
auto result = GUI::InputBox::show(window(), password, "Password"sv, "Password required"sv, {}, GUI::InputType::Password);
|
||||
if (result == GUI::Dialog::ExecResult::OK
|
||||
&& document->security_handler()->try_provide_user_password(password))
|
||||
break;
|
||||
if (result == GUI::Dialog::ExecResult::Cancel)
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
TRY(document->initialize());
|
||||
|
|
Loading…
Reference in a new issue