[rekonq] Websnap::imagePathFromUrl() update proposal
Michael Martín Moro
sexymimi64 at gmail.com
Sat May 29 00:00:55 CEST 2010
Hi there !
I faced a bug with imagePathFromUrl (some websnaps doesn't get printed in my
speed dial) so I checked it out and I found a the quick'n'dirty
imagePathFromUrl() method, which removes some chars in order to make them
suitable as filenames. I also saw the comment about "do something better,
learn regular expressions".
I don't believe we need someone knowing regular expression to do that (I can
do regular expressions but we don't really need those in that case and with
QString). So here is what I came up with, it's easy, not as clean as it
could be, but it should do the trick :
QStringList toReplace, replacers;
>
>
>> toReplace << "%" << "/" << "&" << "," << "+" << "$" << ":" << ";" <<
>> "=" << "?" << "@" << "#" << "\\" << "|";
>
> replacers << "%25" << "%2F" << "%26" << "%2C" << "%2B" << "%24" <<
>> "%3A" << "%3B" << "%3D" << "%3F" << "%40" << "%23" << "%5C" << "%7C";
>
> while (!(toReplace.empty()) && !(replacers.empty()))
>
> name.replace(toReplace.takeFirst(), replacers.takeFirst());
>
>
I joined a diff file to the mail.
Hope I've been helpfull : I have some issues with kdelibs4-dev so I can't
test it right now, but I believe this should compile and work
out-of-the-box.
+++++++++++++++++
Michaël Martín Moro
Epitech 2013
+++++++++++++++++
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/rekonq/attachments/20100529/07a60fce/attachment.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: websnap.cpp.diff
Type: text/x-patch
Size: 753 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/rekonq/attachments/20100529/07a60fce/attachment.diff
More information about the rekonq
mailing list