[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 =?iso-8859-15?q?L=FCbking?= <thomas.luebking () web ! de>
Date: 2009-08-18 13:41:46
Message-ID: 200908181541.46998.thomas.luebking () web ! de
[Download RAW message or body]
... forgot to attach the sample regarding _<unicode>_ insertion... (and
sanitized testing)
["objectnametest.cc" (text/x-c++src)]
//#define QT_NO_CAST_FROM_ASCII
//#define QT_NO_CAST_TO_ASCII
#include <QObject>
#include <QRegExp>
#include <QtDebug>
bool isIdentifier(const QChar &c)
{
return (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
c == '_' ||
(c >= '1' && c <= '9');
}
main (int argc, char **argv)
{
if (argc < 2)
qDebug() << "you forgot the object name";
else
{
QObject o; o.setObjectName(QString::fromUtf8(argv[1]));
qDebug() << o.objectName() << o.objectName().length();
QString string = o.objectName();
for (int i = 0; i < string.length(); ++i)
if (!isIdentifier(string[i]))
{
QString unicode = QString::number(string[i].unicode()) + '_';
string[i] = '_';
string.insert(i+1, unicode);
i += unicode.length();
}
qDebug() << string << string.length();
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic