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

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
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 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.
Revision history for this message
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
=== modified file 'src/view/abstracttexteditor.cpp'
--- src/view/abstracttexteditor.cpp 2015-04-27 15:37:18 +0000
+++ src/view/abstracttexteditor.cpp 2015-04-27 17:02:49 +0000
@@ -1098,7 +1098,7 @@
1098 }1098 }
10991099
1100 int currentOffset = text()->surroundingOffset();1100 int currentOffset = text()->surroundingOffset();
1101 if(currentOffset > 1 && !text()->surrounding().isEmpty()) {1101 if(currentOffset > 1 && currentOffset <= text()->surrounding().size()) {
1102 QString lastChar;1102 QString lastChar;
1103 if(uncommittedDelete) {1103 if(uncommittedDelete) {
1104 // -2 for just deleted character that hasn't been committed and to reach character before cursor1104 // -2 for just deleted character that hasn't been committed and to reach character before cursor
11051105
=== modified file 'tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp'
--- tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp 2014-05-16 16:12:46 +0000
+++ tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp 2015-04-27 17:02:49 +0000
@@ -207,6 +207,38 @@
207 QCOMPARE(host->keyEventCount(), 4);207 QCOMPARE(host->keyEventCount(), 4);
208 }208 }
209209
210 Q_SLOT void testInvalidSurroundingText_data()
211 {
212 QTest::addColumn<Method>("initiate");
213 Method release = &Editor::onKeyReleased;
214
215 QTest::newRow("release") << release;
216 }
217
218 /*
219 * Verifies that the keyboard doesn't crash when pressing backspace with
220 * invalid surrounding text data.
221 */
222 Q_SLOT void testInvalidSurroundingText()
223 {
224 QFETCH(Method, initiate);
225
226 editor->wordEngine()->setEnabled(true);
227 editor->setPreeditEnabled(true);
228 editor->onHasSelectionChanged(false);
229 editor->text()->setSurrounding("123");
230 editor->text()->setSurroundingOffset(9);
231
232 Key backspace;
233 backspace.setAction(Key::ActionBackspace);
234
235 (editor.data()->*initiate)(backspace);
236 editor->onKeyReleased(backspace);
237 editor->checkPreeditReentry(true);
238 QCOMPARE(host->keyEventCount(), 2);
239 }
240
241
210};242};
211243
212QTEST_MAIN(TestRepeatBackspace)244QTEST_MAIN(TestRepeatBackspace)

Subscribers

People subscribed via source and target branches