BPackageInfo::Parser: Validate URL strings.

Fixes #12710.

Signed-off-by: Augustin Cavalier <[email protected]>
I fixed the modifications to the Jamfiles in src/bin, they were all wrong
in the patch.
This commit is contained in:
Andrew Lindesay
2016-06-18 18:40:07 -04:00
committed by Augustin Cavalier
parent a4f86e7f78
commit fa2dd9c45f
18 changed files with 502 additions and 56 deletions
+15 -10
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010 Haiku Inc. All rights reserved.
* Copyright 2010-2016 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _B_URL_H_
@@ -33,7 +33,7 @@ public:
BUrl& SetPath(const BString& path);
BUrl& SetRequest(const BString& request);
BUrl& SetFragment(const BString& fragment);
// URL fields access
const BString& UrlString() const;
const BString& Protocol() const;
@@ -46,7 +46,7 @@ public:
const BString& Path() const;
const BString& Request() const;
const BString& Fragment() const;
// URL fields tests
bool IsValid() const;
bool HasProtocol() const;
@@ -64,21 +64,25 @@ public:
void UrlEncode(bool strict = false);
void UrlDecode(bool strict = false);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
status_t IDNAToAscii();
status_t IDNAToUnicode();
#endif
// Url encoding/decoding of strings
static BString UrlEncode(const BString& url,
bool strict = false,
static BString UrlEncode(const BString& url,
bool strict = false,
bool directory = false);
static BString UrlDecode(const BString& url,
static BString UrlDecode(const BString& url,
bool strict = false);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
// utility functionality
bool HasPreferredApplication() const;
BString PreferredApplication() const;
status_t OpenWithPreferredApplication(
bool onProblemAskUser = true) const;
#endif
// BArchivable members
virtual status_t Archive(BMessage* into,
@@ -93,19 +97,20 @@ public:
const BUrl& operator=(const BUrl& other);
const BUrl& operator=(const BString& string);
const BUrl& operator=(const char* string);
// URL to string conversion
operator const char*() const;
private:
void _ResetFields();
bool _ContainsDelimiter(const BString& url);
void _ExplodeUrlString(const BString& urlString);
BString _MergePath(const BString& relative) const;
void _SetPathUnsafe(const BString& path);
static BString _DoUrlEncodeChunk(const BString& chunk,
static BString _DoUrlEncodeChunk(const BString& chunk,
bool strict, bool directory = false);
static BString _DoUrlDecodeChunk(const BString& chunk,
static BString _DoUrlDecodeChunk(const BString& chunk,
bool strict);
bool _IsProtocolValid();
@@ -128,7 +133,7 @@ private:
BString fPath;
BString fRequest;
BString fFragment;
mutable bool fUrlStringValid : 1;
mutable bool fAuthorityValid : 1;
mutable bool fUserInfoValid : 1;