1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibGUI+Browser: Do not paste bitmaps

This prevents GUI::TextBox and the `Paste & Go` action in the browser
from trying to paste a bitmap. Also, the paste action is enabled
and disabled on clipboard change to reflect if the clipboard data
can be pasted.
This commit is contained in:
TheFightingCatfish 2021-07-25 17:59:30 +08:00 committed by Andreas Kling
parent c4eaba6c88
commit 9b78ae5149
2 changed files with 12 additions and 1 deletions

View file

@ -151,7 +151,12 @@ Tab::Tab(BrowserWindow& window, Type type)
};
m_location_box->add_custom_context_menu_action(GUI::Action::create("Paste && Go", [this](auto&) {
m_location_box->set_text(GUI::Clipboard::the().data());
if (!GUI::Clipboard::the().mime_type().starts_with("text/"))
return;
auto const& paste_text = GUI::Clipboard::the().data();
if (paste_text.is_empty())
return;
m_location_box->set_text(paste_text);
m_location_box->on_return_pressed();
}));