On Wednesday, 17 de August de 2011 11:19:11 David Faure wrote: > > - the setters will take an extra flag of type QUrl::ParsingMode > >(StrictMode> > > and TolerantMode). Default should be TolerantMode. > > What about the QUrl(QString) constructor? Can you make it parse in tolerant > mode? Ideally, could it accept both local paths and urls, like KUrl does?
We spent a lot of time discussing paths and URIs, but not the strict mode.
Is there value in having the strict mode?
What happens if I do:
url.setPath("bar%foo", QUrl::StrictMode); ?
Right now, it's undefined behaviour. The code I wrote will attempt to decode
'f' and 'o' as hex chars and calculate a ushort of
('f' - 'a' + 0xA) << 4 | ('o' - 'a' + 0xA)
0xf0 | 0x18
0xf8
If you have a % at the end of the string, it will even read past the end of
the string and get lost because the pointer will never match the end.
The only advantage of the StrictMode is to allow one to skip the tolerant
corrector, which is O(n), if you know that your data is already properly
encoded, as in coming from QUrl already.
If we decide to remove it, I can change the URL recoder to deal with improper
URLs instead of going into undefined behaviour. This will add a little overhead
to the recoder, but I believe the combination of the corrector and the recoder
has more overhead. Right now, parsing in tolerant mode requires scanning the
string twice from the beginning to the end. And in the worst case scenario
(incorrect string that requires recoding, like "\1%"), there will be two
memory allocations.
For the moment, I'll leave it like it is right now.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
