vcl/unx/gtk3/a11y/atktext.cxx |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 4dc2d5ec7a375f5543f3fba8c1e56988c0e8067f
Author:     Colomban Wendling <cwendl...@hypra.fr>
AuthorDate: Tue May 9 18:30:12 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue May 23 21:44:27 2023 +0200

    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.wegh...@posteo.de>

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,

Reply via email to