Merge lp:~michael-sheldon/ubuntu-keyboard/fix-oxide-crash-rtm into lp:ubuntu-keyboard/rtm-14.09

Proposed by Michael Sheldon on 2015-04-27
Status: Merged
Approved by: Bill Filler on 2015-04-30
Approved revision: 245
Merged at revision: 245
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-oxide-crash-rtm
Merge into: lp:ubuntu-keyboard/rtm-14.09
Diff against target: 55 lines (+33/-1)
2 files modified
src/view/abstracttexteditor.cpp (+1/-1)
tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp (+32/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-oxide-crash-rtm
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team 2015-04-27 Pending
Review via email: mp+257548@code.launchpad.net

Commit message

Back port fix for keyboard crashing when clients send invalid surrounding text/offset data.

Description of the change

Back port fix for keyboard crashing when clients send invalid surrounding text/offset data.

To post a comment you must log in.
Michael Sheldon (michael-sheldon) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes (in sync with RTM branch)

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/ubuntu-keyboard) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * No change

If you changed UI labels, did you update the pot file?

 * No change

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?

 * No change

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/view/abstracttexteditor.cpp'
2--- src/view/abstracttexteditor.cpp 2015-04-27 15:37:18 +0000
3+++ src/view/abstracttexteditor.cpp 2015-04-27 17:02:49 +0000
4@@ -1098,7 +1098,7 @@
5 }
6
7 int currentOffset = text()->surroundingOffset();
8- if(currentOffset > 1 && !text()->surrounding().isEmpty()) {
9+ if(currentOffset > 1 && currentOffset <= text()->surrounding().size()) {
10 QString lastChar;
11 if(uncommittedDelete) {
12 // -2 for just deleted character that hasn't been committed and to reach character before cursor
13
14=== modified file 'tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp'
15--- tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp 2014-05-16 16:12:46 +0000
16+++ tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp 2015-04-27 17:02:49 +0000
17@@ -207,6 +207,38 @@
18 QCOMPARE(host->keyEventCount(), 4);
19 }
20
21+ Q_SLOT void testInvalidSurroundingText_data()
22+ {
23+ QTest::addColumn<Method>("initiate");
24+ Method release = &Editor::onKeyReleased;
25+
26+ QTest::newRow("release") << release;
27+ }
28+
29+ /*
30+ * Verifies that the keyboard doesn't crash when pressing backspace with
31+ * invalid surrounding text data.
32+ */
33+ Q_SLOT void testInvalidSurroundingText()
34+ {
35+ QFETCH(Method, initiate);
36+
37+ editor->wordEngine()->setEnabled(true);
38+ editor->setPreeditEnabled(true);
39+ editor->onHasSelectionChanged(false);
40+ editor->text()->setSurrounding("123");
41+ editor->text()->setSurroundingOffset(9);
42+
43+ Key backspace;
44+ backspace.setAction(Key::ActionBackspace);
45+
46+ (editor.data()->*initiate)(backspace);
47+ editor->onKeyReleased(backspace);
48+ editor->checkPreeditReentry(true);
49+ QCOMPARE(host->keyEventCount(), 2);
50+ }
51+
52+
53 };
54
55 QTEST_MAIN(TestRepeatBackspace)

Subscribers

People subscribed via source and target branches