aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2020-04-23 23:10:48 -0700
committerRoland Knall <rknall@gmail.com>2020-04-24 11:27:39 +0000
commitba50c5a5f6b0edb6b06496de9c3f9d5b18f6cd1e (patch)
tree323ab1915e1daca3de32cf22efb7653f556b5a1a /ui
parent48f87bc3ee504f0bf9c9c2812d090ea3fca39566 (diff)
Check the validator in ExtArgText::isValid().
The validator doesn't prevent the input focus from being transferred out of the QLineEdit, and it merely prevents the user from entering a value that's considered "invalid" rather than "not valid but "intermediate"". For QIntValidator(), values that have more digits than the maximum value are "invalid", but values that have the same number of digits but that are larger are just "intermediate". This means the user will be able to send such a value to the extcap module. So we explicitly check the validator in ExtArgText::isValid(), so that 1) we provide visual feedback (at least to people who can detect a red background) for out-of-range values that don't have too many digits and 2) prevent them from being treated as valid and passed to the extcap module. Bug: 16510 Change-Id: Ie5b90cf5dbb57c91744f6a28a71674b65ef21bb6 Reviewed-on: https://code.wireshark.org/review/36914 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/extcap_argument.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp
index e7e5f4a736..ed7884eb25 100644
--- a/ui/qt/extcap_argument.cpp
+++ b/ui/qt/extcap_argument.cpp
@@ -451,6 +451,34 @@ bool ExtArgText::isValid()
if (isRequired() && value().length() == 0)
valid = false;
+ /* Does the validator, if any, consider the value valid?
+ *
+ * If it considers it an "intermediate" value, rather than an "invalid"
+ * value, the user will be able to transfer the input focus to another
+ * widget, and, as long as all widgets have values for which isValid()
+ * is true, they wil be able to click the "Start" button.
+ *
+ * For QIntValidator(), used for integral fields with minimum and
+ * maximum values, a value that's larger than the maximum but has
+ * the same number of digits as the maximum is "intermediate" rather
+ * than "invalid", so the user will be able to cause that value to
+ * be passed to the extcap module; see bug 16510.
+ *
+ * So we explicitly call the hasAcceptableInput() method on the
+ * text box; that returns false if the value is not "valid", and
+ * that includes "intermediate" values.
+ *
+ * This way, 1) non-colorblind users are informed that the value
+ * is invalid by the text box background being red (perhaps the
+ * user isn't fully colorblind, or perhaps the background is a
+ * noticeably different grayscale), and 2) the user won't be able
+ * to start the capture until they fix the problem.
+ *
+ * XXX - it might be nice to have some way of indicating to the
+ * user what the problem is with the value - alert box? Tooltip? */
+ if (!textBox->hasAcceptableInput())
+ valid = false;
+
/* validation should only be checked if there is a value. if the argument
* must be present (isRequired) the check above will handle that */
if (valid && _argument->regexp != NULL && value().length() > 0)