[haiku-commits] haiku: hrev47425 - src/apps/webpositive src/kits/network/libnetapi headers/os/net

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 25 Jun 2014 10:46:01 +0200 (CEST)

hrev47425 adds 1 changeset to branch 'master'
old head: 6bcbdcc3c0fe914ba61def3185e69b3cf3f48f4d
new head: 158ae743734bb0a3900702317943df71586fbce4
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=158ae74+%5E6bcbdcc

----------------------------------------------------------------------------

158ae74: 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.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev47425
Commit:      158ae743734bb0a3900702317943df71586fbce4
URL:         http://cgit.haiku-os.org/haiku/commit/?id=158ae74
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Jun 25 08:40:51 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/10964

----------------------------------------------------------------------------

4 files changed, 28 insertions(+), 4 deletions(-)
headers/os/net/Url.h                   |  2 ++
src/apps/webpositive/BrowserApp.cpp    |  7 ++++---
src/apps/webpositive/BrowserWindow.cpp |  5 ++++-
src/kits/network/libnetapi/Url.cpp     | 18 ++++++++++++++++++

----------------------------------------------------------------------------

diff --git a/headers/os/net/Url.h b/headers/os/net/Url.h
index 06dc604..0363989 100644
--- a/headers/os/net/Url.h
+++ b/headers/os/net/Url.h
@@ -8,6 +8,7 @@
 
 #include <Archivable.h>
 #include <Message.h>
+#include <Path.h>
 #include <String.h>
 
 
@@ -17,6 +18,7 @@ public:
                                                                BUrl(BMessage* 
archive);
                                                                BUrl(const 
BUrl& other);
                                                                BUrl(const 
BUrl& base, const BString& relative);
+                                                               BUrl(const 
BPath& path);
                                                                BUrl();
        virtual                                         ~BUrl();
 
diff --git a/src/apps/webpositive/BrowserApp.cpp 
b/src/apps/webpositive/BrowserApp.cpp
index bd419ea..5243513 100644
--- a/src/apps/webpositive/BrowserApp.cpp
+++ b/src/apps/webpositive/BrowserApp.cpp
@@ -372,6 +372,7 @@ void
 BrowserApp::_RefsReceived(BMessage* message, int32* _pagesCreated,
        bool* _fullscreen)
 {
+       puts("refs!");
        int32 pagesCreated = 0;
 
        BrowserWindow* window = NULL;
@@ -390,9 +391,9 @@ BrowserApp::_RefsReceived(BMessage* message, int32* 
_pagesCreated,
                BPath path;
                if (entry.GetPath(&path) != B_OK)
                        continue;
-               BString url;
-               url << path.Path();
-               window = _CreateNewPage(url, window, fullscreen, pagesCreated 
== 0);
+               BUrl url(path);
+               window = _CreateNewPage(url.UrlString(), window, fullscreen,
+                       pagesCreated == 0);
                pagesCreated++;
        }
 
diff --git a/src/apps/webpositive/BrowserWindow.cpp 
b/src/apps/webpositive/BrowserWindow.cpp
index c177aa0..7b25f92 100644
--- a/src/apps/webpositive/BrowserWindow.cpp
+++ b/src/apps/webpositive/BrowserWindow.cpp
@@ -68,6 +68,7 @@
 #include <StringView.h>
 #include <TextControl.h>
 #include <UnicodeChar.h>
+#include <Url.h>
 
 #include <map>
 #include <stdio.h>
@@ -967,7 +968,9 @@ BrowserWindow::MessageReceived(BMessage* message)
                        BPath path;
                        if (!entry.Exists() || entry.GetPath(&path) != B_OK)
                                break;
-                       CurrentWebView()->LoadURL(path.Path());
+
+                       BUrl url(path);
+                       CurrentWebView()->LoadURL(url);
                        break;
                }
 
diff --git a/src/kits/network/libnetapi/Url.cpp 
b/src/kits/network/libnetapi/Url.cpp
index a32d147..fb1d499 100644
--- a/src/kits/network/libnetapi/Url.cpp
+++ b/src/kits/network/libnetapi/Url.cpp
@@ -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()
 {
 }


Other related posts: