diff options
author | Colomban Wendling <cwendling@hypra.fr> | 2023-05-09 18:30:12 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-05-23 21:44:27 +0200 |
commit | 4dc2d5ec7a375f5543f3fba8c1e56988c0e8067f (patch) | |
tree | c367ad9f2e438dd2ca1b149144b582cdacb25e1d /vcl | |
parent | 980b5f2676c3a57022893c244617a61594c5f696 (diff) |
gtk a11y: Return 0xFFFFFFFF for invalid characters
Make get_character_at_offset() return 0xFFFFFFFF if fetching the
character fails, including when querying an unpaired surrogate.
https://docs.gtk.org/atspi2/method.Text.get_character_at_offset.html
Change-Id: If5e2e3b6bbd4cbc86b2b8524f305f8f0d843019d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151591
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/a11y/atktext.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/vcl/unx/gtk3/a11y/atktext.cxx b/vcl/unx/gtk3/a11y/atktext.cxx index b898538095cf..e8ceab3bb657 100644 --- a/vcl/unx/gtk3/a11y/atktext.cxx +++ b/vcl/unx/gtk3/a11y/atktext.cxx @@ -22,6 +22,7 @@ #include <algorithm> #include <osl/diagnose.h> +#include <rtl/character.hxx> #include <com/sun/star/accessibility/AccessibleScrollType.hpp> #include <com/sun/star/accessibility/AccessibleTextType.hpp> @@ -101,6 +102,10 @@ adjust_boundaries( css::uno::Reference<css::accessibility::XAccessibleText> cons switch(boundary_type) { case ATK_TEXT_BOUNDARY_CHAR: + if ((rTextSegment.SegmentEnd - rTextSegment.SegmentStart) == 1 + && rtl::isSurrogate(rTextSegment.SegmentText[0])) + return nullptr; + [[fallthrough]]; case ATK_TEXT_BOUNDARY_LINE_START: case ATK_TEXT_BOUNDARY_LINE_END: case ATK_TEXT_BOUNDARY_SENTENCE_START: @@ -351,7 +356,7 @@ text_wrapper_get_character_at_offset (AtkText *text, gint offset) { gint start, end; - gunichar uc = 0; + gunichar uc = 0xFFFFFFFF; gchar * char_as_string = text_wrapper_get_text_at_offset(text, offset, ATK_TEXT_BOUNDARY_CHAR, |