Editbox regexp validation is completely broken.

Create issue
Issue #964 resolved
Paul Turner created an issue

The behaviour of whether a string change should be accepted or not is completely incorrect. The function:

bool Editbox::handleValidityChangeForString(const String& str);

controls this, and does at least two things wrong. First, if the state is Editbox string state is currently invalid and the string change results in the string still being invalid, the change is by default allowed to pass.

The second thing is when there is no handler assigned, the text will always be rejected, unless it gets passed by the bug condition described in the paragraph above.

The function needs to be completely rewritten to behave correctly.

Reproducibility: always

Steps to reproduce: Using the EditboxValidationDemo:

1) Edit the code to not subscribe the validation state changed event. 2) Observe strange behaviour (initial digit rejected, all else accepted).

Expected behaviour: With the regex: "[0-9]{4}" without a handler to deal with the partial match cases, the default CEGUI behaviour should be to reject all input except a paste of four digits (because the string, initially empty, can never match when otherwise edited.

Comments (1)

  1. Log in to comment