Integrated: 8303026: [TextField] IOOBE on setting text with control characters that replaces existing text

Jose Pereda jpereda at openjdk.org
Thu Mar 2 15:54:22 UTC 2023


On Tue, 21 Feb 2023 23:11:52 GMT, Jose Pereda <jpereda at openjdk.org> wrote:

> This PR fixes a regression after [JDK-8212102](https://bugs.openjdk.org/browse/JDK-8212102).
> 
> When a TextField control has some previous content, and new text with only invalid characters (0x7F, new line, tabs, <0x20) is set, `TextInputControl::filterInput` is used to strip them out, and the new text has length 0.
> 
> During the refactoring in JDK-8212102, the checks:
> 
> int length = txt.length();
> if (end > start + length) end = length;
> if (start > length-1) start = end = 0;
> 
> were removed. 
> 
> In this particular case, when the new filtered text has length 0, we need those checks, so start and end are set to 0, and txt.substring(start, end) doesn't throw the IOOBE anymore.
> 
> A test is added to verify this scenario. It fails with the proposed patch, passes with it.

This pull request has now been integrated.

Changeset: 9df6039a
Author:    Jose Pereda <jpereda at openjdk.org>
URL:       https://git.openjdk.org/jfx/commit/9df6039a27a78f40a929b5ba4de0e38ce233a6fc
Stats:     16 lines in 2 files changed: 14 ins; 0 del; 2 mod

8303026: [TextField] IOOBE on setting text with control characters that replaces existing text

Reviewed-by: angorya, arapte

-------------

PR: https://git.openjdk.org/jfx/pull/1043


More information about the openjfx-dev mailing list