[Libreoffice-commits] core.git: sw/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 3 15:17:57 UTC 2020
sw/source/uibase/uitest/uiobject.cxx | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
New commits:
commit 482590eec84d8460d4e7a79031ce9edcd83be1ad
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Sat Aug 1 11:22:10 2020 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Aug 3 17:17:14 2020 +0200
Validate SELECT range
63049e98a659290229d3356e76d49cea44575011 "Reliably set up controls of hyperlink
dialog in constructor" fixed an issue that could cause Python UITest code to
issue a bogus SELECT request that would fire an assert in
rtl_uString_newFromSubString. Even if that issue is fixed now, it is probably a
good idea to validate the requested range here.
(An alternative would be to validate it in the underlying shell's SelectText,
but that function is also called from internal code (which presumably already
ensures that it is passing valid arguments), so it is probably better to stay
with that function's narrow interface.)
It would probably be nice if this function reported failure (by throwing a
css::lang::IllegalArgumentException, say) instead of silently (modulo SAL_WARN)
clamping the range, but it is called from Scheduler::ProcessTaskScheduling
(vcl/source/app/scheduler.cxx) in a try/catch block that prohibits all
exceptions.
Change-Id: I5b7b4255861766a81a81501e391b1ff4e09b7db6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99933
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/source/uibase/uitest/uiobject.cxx b/sw/source/uibase/uitest/uiobject.cxx
index 85b261ea87b9..4ac900ec635c 100644
--- a/sw/source/uibase/uitest/uiobject.cxx
+++ b/sw/source/uibase/uitest/uiobject.cxx
@@ -13,6 +13,7 @@
#include <view.hxx>
#include <wrtsh.hxx>
#include <navipi.hxx>
+#include <ndtxt.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
#include <sfx2/viewfrm.hxx>
@@ -101,7 +102,18 @@ void SwEditWinUIObject::execute(const OUString& rAction,
OUString aEndPos = itr->second;
sal_Int32 nEndPos = aEndPos.toInt32();
- getWrtShell(mxEditWin).SelectText(nStartPos, nEndPos);
+ auto & shell = getWrtShell(mxEditWin);
+ sal_Int32 len;
+ if (auto const text = shell.GetCursor_()->GetPoint()->nNode.GetNode().GetTextNode()) {
+ len = text->GetText().getLength();
+ } else {
+ len = 0;
+ }
+ SAL_WARN_IF(
+ nStartPos < 0 || nStartPos > len || nEndPos < 0 || nEndPos > len, "sw.ui",
+ "SELECT START/END_POS " << nStartPos << ".." << nEndPos << " outside 0.." << len);
+ shell.SelectText(
+ std::clamp(nStartPos, sal_Int32(0), len), std::clamp(nEndPos, sal_Int32(0), len));
}
}
else if (rAction == "SIDEBAR")
More information about the Libreoffice-commits
mailing list