[Telepathy-commits] [telepathy-qt4/master] Proper parse key/values with spaces.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Mon Jan 5 08:16:40 PST 2009


---
 TelepathyQt4/key-file.cpp |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/TelepathyQt4/key-file.cpp b/TelepathyQt4/key-file.cpp
index 6c8538f..3fc498e 100644
--- a/TelepathyQt4/key-file.cpp
+++ b/TelepathyQt4/key-file.cpp
@@ -161,12 +161,13 @@ bool KeyFile::Private::read()
 
             // remove trailing spaces
             char ch;
-            while ((ch = data.at(idx - 1)) == ' ' || ch == '\t') {
-                --idx;
+            int idxKeyEnd = idx;
+            while ((ch = data.at(idxKeyEnd - 1)) == ' ' || ch == '\t') {
+                --idxKeyEnd;
             }
 
             QString key;
-            if (!validateKey(data, 0, idx, key)) {
+            if (!validateKey(data, 0, idxKeyEnd, key)) {
                 setError(KeyFile::FormatError,
                          QString("invalid key '%1' at line %2")
                                  .arg(key).arg(line));
-- 
1.5.6.5




More information about the Telepathy-commits mailing list