url-encoded paths and QString::arg()

Jeff Mitchell kde-dev at emailgoeshere.com
Sun Aug 3 01:56:03 CEST 2008


On Saturday 02 August 2008, Edward Hades wrote:
> Hey, guys,
>
> I just found a curious piece of misfortune that happens when these two
> guys in subject are brought together in single C++ statement.
>
> Consider the following statement (which there was at least one in
> Amarok, see r841272):
>
> QString( "INSERT INTO table VALUES ( %1, '%2', '%3' )" ).arg( whatever
> ).arg( rpath ).arg( someotherdata );
>
> If rpath contains %3f, or %20, or something like that, the
> someotherdata get inserted there, instead of where sane people would
> normally expect.
>
> This results in curious SQL statements like:
> INSERT INTO uniqueid_temp(deviceid,rpath,uniqueid) VALUES
> (-1,'./mnt/media/Music/Best of Jazz instrumentals/Best of - 02 - Urban
> Knight 118b02960c18f41752495907c88359bdF Scirrocco.flac','%3');

I did some digging:

http://doc.trolltech.com/4.4/qstring.html#arg-2

Looks like we may have to use that syntax anywhere we're handling a path or 
URL with .args.  There are versions of that function for up to 9 arguments.

--Jeff


More information about the Amarok-devel mailing list