From 18e99b5a41aa502c09f80095e442717ed9cfa5a2 Mon Sep 17 00:00:00 2001 From: sniperbeamer Date: Fri, 15 Feb 2008 19:49:13 +0000 Subject: [PATCH] auto-type and auto-type-window definitions are now fully compatible with keepass git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@151 b624d157-de02-0410-bad0-e51aec6abb33 --- src/lib/AutoType_X11.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/lib/AutoType_X11.cpp b/src/lib/AutoType_X11.cpp index 91afaf9..078dc0b 100644 --- a/src/lib/AutoType_X11.cpp +++ b/src/lib/AutoType_X11.cpp @@ -60,27 +60,25 @@ Shortcut AutoType::shortcut; void AutoType::perform(IEntryHandle* entry, QString& err,bool hideWindow,int nr){ QString indexStr; if (nr==0) - indexStr = "Auto-Type: "; + indexStr = "Auto-Type:"; else - indexStr = QString("Auto-Type-%1: ").arg(nr); + indexStr = QString("Auto-Type-%1:").arg(nr); QString str; QString comment=entry->comment(); - int c=comment.count(indexStr); + int c=comment.count(indexStr, Qt::CaseInsensitive); if(c>1){ err=QCoreApplication::translate("AutoType","More than one 'Auto-Type:' key sequence found.\nAllowed is only one per entry."); return; } - if(c==1){ - int indexLen = indexStr.length(); - int start=comment.indexOf(indexStr)+indexLen; - int len; - if(comment.size()==indexLen)return; - for(len=0;len validEntries; QList entryNumbers; QList entries = MainWin->db->entries(); - QRegExp lineMatch("^Auto-Type-Window(?:-(\\d+)|): (.+)$", Qt::CaseSensitive, QRegExp::RegExp2); + QRegExp lineMatch("Auto-Type-Window(?:-(\\d+)|):([^\\n]+)", Qt::CaseInsensitive, QRegExp::RegExp2); QDateTime now = QDateTime::currentDateTime(); for (int i=0; iexpire()!=Date_Never && entries[i]->expire()comment().split("\n", QString::SkipEmptyParts); - for (int j=0; jcomment(); + int offset = 0; + while ( (offset=lineMatch.indexIn(comment, offset))!=-1 ){ QStringList captured = lineMatch.capturedTexts(); + offset += captured[0].length(); int nr; QString entryWindow; bool valid; if (captured.size()==2){ nr = 0; - entryWindow = captured[1].toLower(); + entryWindow = captured[1].trimmed().toLower(); } else{ nr = captured[1].toInt(); - entryWindow = captured[2].toLower(); + entryWindow = captured[2].trimmed().toLower(); } if (entryWindow.length()==0) continue;