Hello all So I've given some thought on QUrl in Qt 5, based on experience with improving it in Qt 4 as well as KUrl. Here's the major guidelines:
- remove all QByteArray-based and "encoded" functions (encodedUserName,
encodedPassword, setEncodedPath, etc.)
- change all QString setters and getters to operate on percent-encoded
values, still using QString
- the setters will take an extra flag of type QUrl::ParsingMode (StrictMode
and TolerantMode). Default should be TolerantMode.
- the getters will take a new, extra flag which should contain:
FullyEncoded = 0x00
DecodeSpaces = 0x01
DecodeDelimiters = 0x02
DecodeUnicode = 0x04
the default value in all those functions should be 0x07. For keeping of source
compatibility, toEncoded is equivalent to toString(FullyEncoded), except that
it will return a QString, not a QByteArray as today.
- to understand those modes, imagine the following URL (yes, it's a URL):
/foo%2fbar/baz%23%3fhello%20world?qr%80%23#blah?r%c3%a9sum%c3%a9
it decomposes in FullyEncoded as:
path = /foo%2fbar/baz%23%3fhello%20world
query = qr%80%23
fragment = blah?r%c3%a9sum%c3%a9
if we add DecodeSpaces, the path becomes:
path = /foo%2fbar/baz%23%3fhello world
if we add DecodeDelimiters, it becomes:
path = /foo%2fbar/baz#?hello world
query = qr%80#
if we add DecodeUnicode, the fragment becomes:
fragment = blah?résumé
toString(0x07) would still be:
/foo%2fbar/baz%23%3fhello world?qr%80%23#blah?résumé
The %80 is never decoded because it cannot be represented in a QString; the
%2f in the path is never decoded because the URI spec says that it's different
from a slash. Finally, since %23 and %3f have special meaning, they still need
to be encoded when more than one component is present (similar rules apply to
those, @ and / in the userinfo).
- I'm wondering: should I add a mode that returns the entry non-normalised?
i.e., if you write:
QUrl("http://localhost/%66%6f%6f")
usually:
path() = "/foo"
but should we have this?
path(Original) = "/%66%6f%6f"
- Add an extra setting to the query setter, allowing:
addQueryItem("foo", "hello world", QUrl::HtmlFormEncoding)
such that the query has "foo=hello+world", as opposed to the URI-
compliant "foo=hello%20world"
- deviate from the URI spec and treat the plus sign as a reserved character
in queries. The objective is that "%2b" is never decoded to "+": it's always
kept as-is.
- fix QUrl's thread-safety issues. Lazy parsing, implicit sharing and thread-
safety aren't easy to get all together.
- remove Qt3Support and deprecated methods (fromPunycode / toPunycode)
- deprecate but not remove toPercentEncoding and fromPercentEncoding -- use
QByteArray instead
--
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
