Escape reserved characters when converting paths to urls
* Introduce and use BUrl::BUrl(const BPath&) * The path is url-encoded, and the protocol is set to "file" Fixes #10964.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Archivable.h>
|
#include <Archivable.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <Path.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ public:
|
|||||||
BUrl(BMessage* archive);
|
BUrl(BMessage* archive);
|
||||||
BUrl(const BUrl& other);
|
BUrl(const BUrl& other);
|
||||||
BUrl(const BUrl& base, const BString& relative);
|
BUrl(const BUrl& base, const BString& relative);
|
||||||
|
BUrl(const BPath& path);
|
||||||
BUrl();
|
BUrl();
|
||||||
virtual ~BUrl();
|
virtual ~BUrl();
|
||||||
|
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ void
|
|||||||
BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
|
BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
|
||||||
bool* _fullscreen)
|
bool* _fullscreen)
|
||||||
{
|
{
|
||||||
|
puts("refs!");
|
||||||
int32 pagesCreated = 0;
|
int32 pagesCreated = 0;
|
||||||
|
|
||||||
BrowserWindow* window = NULL;
|
BrowserWindow* window = NULL;
|
||||||
@@ -390,9 +391,9 @@ BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
|
|||||||
BPath path;
|
BPath path;
|
||||||
if (entry.GetPath(&path) != B_OK)
|
if (entry.GetPath(&path) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
BString url;
|
BUrl url(path);
|
||||||
url << path.Path();
|
window = _CreateNewPage(url.UrlString(), window, fullscreen,
|
||||||
window = _CreateNewPage(url, window, fullscreen, pagesCreated == 0);
|
pagesCreated == 0);
|
||||||
pagesCreated++;
|
pagesCreated++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,7 @@
|
|||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <UnicodeChar.h>
|
#include <UnicodeChar.h>
|
||||||
|
#include <Url.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -967,7 +968,9 @@ BrowserWindow::MessageReceived(BMessage* message)
|
|||||||
BPath path;
|
BPath path;
|
||||||
if (!entry.Exists() || entry.GetPath(&path) != B_OK)
|
if (!entry.Exists() || entry.GetPath(&path) != B_OK)
|
||||||
break;
|
break;
|
||||||
CurrentWebView()->LoadURL(path.Path());
|
|
||||||
|
BUrl url(path);
|
||||||
|
CurrentWebView()->LoadURL(url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,24 @@ BUrl::BUrl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BUrl::BUrl(const BPath& path)
|
||||||
|
:
|
||||||
|
fUrlString(),
|
||||||
|
fProtocol(),
|
||||||
|
fUser(),
|
||||||
|
fPassword(),
|
||||||
|
fHost(),
|
||||||
|
fPort(0),
|
||||||
|
fPath(),
|
||||||
|
fRequest(),
|
||||||
|
fHasHost(false),
|
||||||
|
fHasFragment(false)
|
||||||
|
{
|
||||||
|
SetUrlString(UrlEncode(path.Path(), true, true));
|
||||||
|
SetProtocol("file");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BUrl::~BUrl()
|
BUrl::~BUrl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user