Skip to content

Commit 0d84113

Browse files
jascrainraveit65
authored andcommitted
a11y: Return correct start and end offsets
This modifies ev_page_accessible_get_range_for_boundary to ensure that the start and end offsets it returns are within the allowed range. https://bugzilla.gnome.org/show_bug.cgi?id=777992 origin commit: https://git.gnome.org/browse/evince/commit/?id=e95a4e3
1 parent e3ce0a4 commit 0d84113

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎libview/ev-page-accessible.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,32 +543,35 @@ ev_page_accessible_get_range_for_boundary (AtkText *text,
543543
if (!log_attrs)
544544
return;
545545

546+
if (offset < 0 || offset >= n_attrs)
547+
return;
548+
546549
switch (boundary_type) {
547550
case ATK_TEXT_BOUNDARY_CHAR:
548551
start = offset;
549552
end = offset + 1;
550553
break;
551554
case ATK_TEXT_BOUNDARY_WORD_START:
552-
for (start = offset; start >= 0 && !log_attrs[start].is_word_start; start--);
553-
for (end = offset + 1; end <= n_attrs && !log_attrs[end].is_word_start; end++);
555+
for (start = offset; start > 0 && !log_attrs[start].is_word_start; start--);
556+
for (end = offset + 1; end < n_attrs && !log_attrs[end].is_word_start; end++);
554557
break;
555558
case ATK_TEXT_BOUNDARY_SENTENCE_START:
556-
for (start = offset; start >= 0; start--) {
559+
for (start = offset; start > 0; start--) {
557560
if (log_attrs[start].is_mandatory_break && treat_as_soft_return (view, self->priv->page, log_attrs, start - 1))
558561
continue;
559562
if (log_attrs[start].is_sentence_start)
560563
break;
561564
}
562-
for (end = offset + 1; end <= n_attrs; end++) {
565+
for (end = offset + 1; end < n_attrs; end++) {
563566
if (log_attrs[end].is_mandatory_break && treat_as_soft_return (view, self->priv->page, log_attrs, end - 1))
564567
continue;
565568
if (log_attrs[end].is_sentence_start)
566569
break;
567570
}
568571
break;
569572
case ATK_TEXT_BOUNDARY_LINE_START:
570-
for (start = offset; start >= 0 && !log_attrs[start].is_mandatory_break; start--);
571-
for (end = offset + 1; end <= n_attrs && !log_attrs[end].is_mandatory_break; end++);
573+
for (start = offset; start > 0 && !log_attrs[start].is_mandatory_break; start--);
574+
for (end = offset + 1; end < n_attrs && !log_attrs[end].is_mandatory_break; end++);
572575
break;
573576
default:
574577
/* The "END" boundary types are deprecated */

0 commit comments

Comments
 (0)