From kde-core-devel Tue Aug 18 13:41:46 2009 From: Thomas =?iso-8859-15?q?L=FCbking?= Date: Tue, 18 Aug 2009 13:41:46 +0000 To: kde-core-devel Subject: Re: Review Request: Fix sanitization of dbus path in KMainWindow Message-Id: <200908181541.46998.thomas.luebking () web ! de> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=125060339008896 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_a+qiK9INhdZrZGi" --Boundary-00=_a+qiK9INhdZrZGi Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit ... forgot to attach the sample regarding __ insertion... (and sanitized testing) --Boundary-00=_a+qiK9INhdZrZGi Content-Type: text/x-c++src; charset="UTF-8"; name="objectnametest.cc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="objectnametest.cc" //#define QT_NO_CAST_FROM_ASCII //#define QT_NO_CAST_TO_ASCII #include #include #include 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(); } } --Boundary-00=_a+qiK9INhdZrZGi--