BUrl: use a regex to parse URLs

* The RFC provide a regular expression for URI parsing, so just use it.
 * Allows parsing URIs with missing components (no scheme or authority)
 * This allows to parse relative URLs as expected
 * Can also handle things such as data: or mailto:
 * Also more fixes to handling of incomplete URIs, some flags weren't
always set to the right values.

This gets Windows Live Mail (or is it called Outlook?) working, with
some other fixes on WebKit side.
This commit is contained in:
Adrien Destugues
2013-10-16 21:01:43 +02:00
parent 831819980e
commit ced0e0be04
3 changed files with 81 additions and 60 deletions
+2 -2
View File
@@ -16,6 +16,7 @@ public:
BUrl(const char* url);
BUrl(BMessage* archive);
BUrl(const BUrl& other);
BUrl(const BUrl& base, const BString& relative);
BUrl();
virtual ~BUrl();
@@ -24,12 +25,12 @@ public:
BUrl& SetProtocol(const BString& scheme);
BUrl& SetUserName(const BString& user);
BUrl& SetPassword(const BString& password);
void SetAuthority(const BString& authority);
BUrl& SetHost(const BString& host);
BUrl& SetPort(int port);
BUrl& SetPath(const BString& path);
BUrl& SetRequest(const BString& request);
BUrl& SetFragment(const BString& fragment);
void Redirect(const BString& newLocation);
// URL fields access
const BString& UrlString() const;
@@ -88,7 +89,6 @@ public:
private:
void _ResetFields();
void _ExplodeUrlString(const BString& urlString);
void _ExplodeAuthority();
static BString _DoUrlEncodeChunk(const BString& chunk,
bool strict, bool directory = false);