diff options
author | Jason Crain <[email protected]> | 2017-03-26 13:33:29 -0500 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-04-05 17:51:24 +0200 |
commit | 0d841130ffe0c5e222de3d1eec59aa35b8335017 (patch) | |
tree | 5a3aa2a1fd5712a38bbe25d6b9f1852595997355 /libview | |
parent | e3ce0a476ad56a6cbde385fd162ed841efae4d57 (diff) | |
download | atril-0d841130ffe0c5e222de3d1eec59aa35b8335017.tar.bz2 atril-0d841130ffe0c5e222de3d1eec59aa35b8335017.tar.xz |
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
Diffstat (limited to 'libview')
-rw-r--r-- | libview/ev-page-accessible.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libview/ev-page-accessible.c b/libview/ev-page-accessible.c index 13ce8b0d..8d07a31c 100644 --- a/libview/ev-page-accessible.c +++ b/libview/ev-page-accessible.c @@ -543,23 +543,26 @@ ev_page_accessible_get_range_for_boundary (AtkText *text, if (!log_attrs) return; + if (offset < 0 || offset >= n_attrs) + return; + switch (boundary_type) { case ATK_TEXT_BOUNDARY_CHAR: start = offset; end = offset + 1; break; case ATK_TEXT_BOUNDARY_WORD_START: - for (start = offset; start >= 0 && !log_attrs[start].is_word_start; start--); - for (end = offset + 1; end <= n_attrs && !log_attrs[end].is_word_start; end++); + for (start = offset; start > 0 && !log_attrs[start].is_word_start; start--); + for (end = offset + 1; end < n_attrs && !log_attrs[end].is_word_start; end++); break; case ATK_TEXT_BOUNDARY_SENTENCE_START: - for (start = offset; start >= 0; start--) { + for (start = offset; start > 0; start--) { if (log_attrs[start].is_mandatory_break && treat_as_soft_return (view, self->priv->page, log_attrs, start - 1)) continue; if (log_attrs[start].is_sentence_start) break; } - for (end = offset + 1; end <= n_attrs; end++) { + for (end = offset + 1; end < n_attrs; end++) { if (log_attrs[end].is_mandatory_break && treat_as_soft_return (view, self->priv->page, log_attrs, end - 1)) continue; if (log_attrs[end].is_sentence_start) @@ -567,8 +570,8 @@ ev_page_accessible_get_range_for_boundary (AtkText *text, } break; case ATK_TEXT_BOUNDARY_LINE_START: - for (start = offset; start >= 0 && !log_attrs[start].is_mandatory_break; start--); - for (end = offset + 1; end <= n_attrs && !log_attrs[end].is_mandatory_break; end++); + for (start = offset; start > 0 && !log_attrs[start].is_mandatory_break; start--); + for (end = offset + 1; end < n_attrs && !log_attrs[end].is_mandatory_break; end++); break; default: /* The "END" boundary types are deprecated */ |