From kde-core-devel Mon Aug 17 20:20:57 2009 From: Thomas =?utf-8?q?L=C3=BCbking?= Date: Mon, 17 Aug 2009 20:20:57 +0000 To: kde-core-devel Subject: Re: Review Request: Fix sanitization of dbus path in KMainWindow Message-Id: <200908172220.57580.thomas.luebking () web ! de> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=125054328412839 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_pubiKAg9myTplMP" --Boundary-00=_pubiKAg9myTplMP Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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) --Boundary-00=_pubiKAg9myTplMP Content-Type: text/x-c++src; charset="UTF-8"; name="objectnametest.cc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="objectnametest.cc" #include #include #include 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); } } --Boundary-00=_pubiKAg9myTplMP--