Review Request: Fix sanitization of dbus path in KMainWindow
Thomas Lübking
thomas.luebking at web.de
Tue Aug 18 05:38:00 BST 2009
Am Tuesday 18 August 2009 schrieb Matthew Woehlke:
> Thomas Lübking wrote:
> > static inline bool isIdentifier(char c)
> > { // the order btw is [a-zA-Z_0-9]
> > return (c > 96 && c < 123) || (c > 64 && c < 91) ||
> > c == '_' || (c > 47 && c < 58);
> > }
>
> ...did I mention yet I think this should be in QChar? :-)
yupp.
> even). How about this? (Mind the broken line-wrapping.)
actually the code included an offense (scnr)
gcc should be smart enough to optimize "a >= b" to "a > b-1" if b is const and
> 0 at compile time and a and b are POD, so:
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >=
'0' && c <= '9');
should do equal (and is at least less typo prone and more readable)
QChar::toAscii() on the other hand invokes QTextCodec and if
QString::toAscii() isn't a dumb for(;;) loop across QString[i] you can
probably really save some cycles here by operating on the bytearray
(given length() and the data() pointer are inline functions one can however
savely spare those extra assumptions =D )
Regards,
Thomas
More information about the kde-core-devel
mailing list