diff options
author | Daniel Teske <qt@squorn.de> | 2017-06-27 15:10:35 +0200 |
---|---|---|
committer | Daniel Teske <qt@squorn.de> | 2017-07-13 14:59:17 +0000 |
commit | 70515726181a7e97e1a7096f6b63d4320581d5c1 (patch) | |
tree | 161ef666c0dc06c59552059827870b1278d6028b /src/widgets | |
parent | bdca35e8154d6a8cb2232bd32c64c9e0ba3775c4 (diff) |
QLineEdit: Fix length calculation for input mask "\\\\"
Consider the raw string \\\\. The previous algorithm would consider
the last 3 \ to be escaped because the previous character is a \ and
thus calculating a maxLength of 3.
But this should be treated as two escaped \ with a maxLength of 2.
Change-Id: I6c4b8d090a2e1c6e85195d5920ce8b80aea1bc2d
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 905bc0f586..97df3427b0 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -973,12 +973,20 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) // calculate m_maxLength / m_maskData length m_maxLength = 0; QChar c = 0; + bool escaped = false; for (int i=0; i<m_inputMask.length(); i++) { c = m_inputMask.at(i); - if (i > 0 && m_inputMask.at(i-1) == QLatin1Char('\\')) { - m_maxLength++; - continue; + if (escaped) { + ++m_maxLength; + escaped = false; + continue; } + + if (c == '\\') { + escaped = true; + continue; + } + if (c != QLatin1Char('\\') && c != QLatin1Char('!') && c != QLatin1Char('<') && c != QLatin1Char('>') && c != QLatin1Char('{') && c != QLatin1Char('}') && |