summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2024-01-12 13:07:10 +0100
committerAron Budea <aron.budea@collabora.com>2025-01-02 15:05:49 +0100
commitc0c0433d469021ca55d832fb9e85407f3f6705a5 (patch)
tree9d9182d5c802d6239edf68f694db3a30a4176a16
parent3e989d2705ccbf6f8a2904f6c158a4b76ea4920f (diff)
tdf#162753 - Hyperlink dialog: preset only syntactically valid hyperlinks
This backport includes cui: fix typo 3635a2d6d5ba348dfbce05705917fe086e328ada make -srj1 UITest_writer_tests3 \ UITEST_TEST_NAME=hyperlinkdialog.HyperlinkDialog.test_tdf162753_propose_invalid_clipboard_content \ SAL_USE_VCLPLUGIN=gen Change-Id: I682acfa4e41a3cce5f4639d79004bea985cabce3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176112 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178955 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Aron Budea <aron.budea@collabora.com> Reviewed-by: Justin Luth <jluth@mail.com>
-rw-r--r--cui/source/dialogs/hltpbase.cxx8
-rw-r--r--sw/qa/uitest/writer_tests3/hyperlinkdialog.py19
2 files changed, 22 insertions, 5 deletions
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index f0aa7c368c04..8c065fa01f7b 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -465,13 +465,13 @@ void SvxHyperlinkTabPageBase::Reset( const SfxItemSet& rItemSet)
SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, aFlavor);
if (xTransferable->isDataFlavorSupported(aFlavor))
{
- OUString aClipBoardConentent;
+ OUString aClipBoardContent;
try
{
- if (xTransferable->getTransferData(aFlavor) >>= aClipBoardConentent)
+ if (xTransferable->getTransferData(aFlavor) >>= aClipBoardContent)
{
- INetURLObject aURL;
- aURL.SetSmartURL(aClipBoardConentent);
+ // tdf#162753 - allow only syntactically valid hyperlink targets
+ INetURLObject aURL(aClipBoardContent);
if (!aURL.HasError())
aStrURL
= aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
diff --git a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
index 531b5f42a866..0ee8e52c6ffd 100644
--- a/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
+++ b/sw/qa/uitest/writer_tests3/hyperlinkdialog.py
@@ -110,7 +110,7 @@ class HyperlinkDialog(UITestCase):
# Insert a sample URL
xWriterDoc = self.xUITest.getTopFocusWindow()
xWriterEdit = xWriterDoc.getChild("writer_edit")
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "www.libreoffice.org"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org"}))
# Copy URL and open the hyperlink dialog
self.xUITest.executeCommand(".uno:SelectAll")
@@ -122,6 +122,23 @@ class HyperlinkDialog(UITestCase):
xTarget = xDialog.getChild("target")
self.assertEqual(get_state_as_dict(xTarget)["Text"].lower(), "http://www.libreoffice.org/")
+ def test_tdf162753_propose_invalid_clipboard_content(self):
+ with self.ui_test.create_doc_in_start_center("writer"):
+ # Insert an invalid sample URL
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "libreoffice"}))
+
+ # Copy URL and open the hyperlink dialog
+ self.xUITest.executeCommand(".uno:SelectAll")
+ self.xUITest.executeCommand(".uno:Copy")
+ with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", close_button="cancel") as xDialog:
+ xTab = xDialog.getChild("tabcontrol")
+ select_pos(xTab, "0")
+ # Check if the content of the clipboard is not proposed as URL in the hyperlink dialog
+ xTarget = xDialog.getChild("target")
+ self.assertEqual(get_state_as_dict(xTarget)["Text"], "")
+
def test_tdf141166(self):
# Skip this test for --with-help=html and --with-help=online, as that would fail with a
# DialogNotExecutedException("did not execute a dialog for a blocking action") thrown from