[Development] New QUrl implementation

Thiago Macieira thiago.macieira at intel.com
Fri Dec 23 20:03:49 CET 2011


On Friday, 23 de December de 2011 11.29.34, Thiago Macieira wrote:
> https://qt.gitorious.org/~thiago-intel/qt/thiago-intels-
> qtbase/commits/ipaddress-parser

This series of commits does the following:

24976c8 Add a function to parse IPv4 addresses in QtCore

There are two kinds of IPv4 address parsers in the wild:
	inet_aton-style
	inet_pton-style

The inet_aton is the oldest implementation, which allows IP addresses like 
127.1 or 10.0.257. Those types of addresses are not usually considered valid 
and inet_pton will not accept them. The old implementation we had in 
qhostaddress.cpp was compliant with inet_pton. And we had a different 
implementation in qurl.cpp following the grammar set forth in RFC 3986.

The new implementation I wrote is actually more lax and accepts IP addresses 
like inet_aton. The unit test will compare the results between the two to 
ensure we're following it. The reason I did so was because URL parsing very 
often deals with very broken URLs. The unit tests in WebKit in fact do attempt 
such broken addresses.

013a083 Add support for IPv6 parsing and reconstructing the address

Unlike the IPv4 implementation, the IPv6 one is strict. It's in fact stricter 
than the previous one in QHostAddress because it doesn't accept a double-colon 
(::) where none is necessary. The following IP address was previously accepted 
but no longer is:

	2222:2222:2222:2222::3333:3333:3333:3333

It parses v4-compat and v4-mapped addresses but requires strict IPv4 addresses 
(inet_pton style, not inet_aton style). It also reconstructs those mapped 
addresses properly, which the old QUrl didn't.

c5c1650 Port QHostAddress to use the new IP utilities in QtCore

Replace the old IP-address parsing in QHostAddress with the one in QtCore, 
which is way more efficient. I didn't benchmark by how much, but anyone doing a 
cursory comparison can tell.

63e0c52 Optimise QHostAddress a little

Some extra work to make it faster, avoiding parsing of constant strings. 
Instead, simply use the known binary form.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20111223/a24caa85/attachment.sig>


More information about the Development mailing list