[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Review Request: Fix sanitization of dbus path in KMainWindow
From:       Thomas =?utf-8?q?L=C3=BCbking?= <thomas.luebking () web ! de>
Date:       2009-08-17 20:20:57
Message-ID: 200908172220.57580.thomas.luebking () web ! de
[Download RAW message or body]

Am Monday 17 August 2009 schrieb Matthew Woehlke:
> If you'd like to "one-up" my patch, please feel free :-). Otherwise I'm
> not sure what you have in mind.
i guess sth. like

QRegExp identifier("[A-Za-z0-9_]");
o.objectName().mid(i,1).contains(identifier);

Performance ain't crucial here (and QChar::isLetter() just tests some flags), 
but i just tested and QChar grants ::isLetter to really a lot of stuff (esp. 
as any utf-8 char seems to be split an the first part becomes a letter, though 
it's /no/ [A-Za-z] :-(

(new test code attached)

["objectnametest.cc" (text/x-c++src)]

#include <QObject>
#include <QRegExp>
#include <QtDebug>

main (int argc, char **argv)
{
	if (argc < 2)
		qDebug() << "you forgot the object name";
	else
	{
		QObject o; o.setObjectName(argv[1]);
		qDebug() << o.objectName();
        QRegExp identifier("[A-Za-z0-9_]");
        for (int i = 0; i < o.objectName().length(); ++i)
            qDebug() << o.objectName().midRef(i,1) << o.objectName().mid(i,1).contains(identifier);
	}
}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic