gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. 5df8a9b767a65592073b


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 5df8a9b767a65592073b9540cde8b411bef515da
Date: Thu, 04 Nov 2010 08:27:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  5df8a9b767a65592073b9540cde8b411bef515da (commit)
       via  ccf8da18f9b3adfa2c38d5dc025e3890be1a0319 (commit)
       via  00776702a3b6a407dccb7dc2319e0768ddb2156d (commit)
       via  ea602ba0a49444bda2768a6735fcc2ab4ac5d7f5 (commit)
       via  55e712d5141cd67d895774aeb62f57f1e2badd94 (commit)
       via  9bab924d3bedefb7be78594f28eb882fd0db525c (commit)
       via  3b5da9e765b05155172c231d06d1fe347c7abf30 (commit)
       via  fd4ac07c55d64c91e186a03ab338352d99c5fdc6 (commit)
       via  f45362f1c882353b27773cec5a831b0c7293e799 (commit)
       via  ef2819bdf09e1ff27f63100c73fdb25779f2fd62 (commit)
      from  33ede786aa0ccd7556123c270021d760a9a041bd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=5df8a9b767a65592073b9540cde8b411bef515da


commit 5df8a9b767a65592073b9540cde8b411bef515da
Merge: ccf8da1 33ede78
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Nov 4 09:12:38 2010 +0100

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=ccf8da18f9b3adfa2c38d5dc025e3890be1a0319


commit ccf8da18f9b3adfa2c38d5dc025e3890be1a0319
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Nov 4 09:01:28 2010 +0100

    Improve log messages.

diff --git a/gui/Player.cpp b/gui/Player.cpp
index e6121b8..91b2614 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -227,7 +227,6 @@ Player::load_movie()
 
     try {
         if (_infile == "-") {
-            log_debug("Using filno");
             std::auto_ptr<IOChannel> in (
                 noseek_fd_adapter::make_stream(fileno(stdin)));
             md = MovieFactory::makeMovie(in, _url, *_runResources, false);
diff --git a/libcore/MovieFactory.cpp b/libcore/MovieFactory.cpp
index 02221d6..f397cef 100644
--- a/libcore/MovieFactory.cpp
+++ b/libcore/MovieFactory.cpp
@@ -96,7 +96,7 @@ MovieFactory::makeMovie(std::auto_ptr<IOChannel> in, const 
std::string& url,
             return ret;
 
         default:
-            log_error(_("unknown file type (%s)"), type);
+            log_error(_("Unknown file type"));
             break;
     }
 

http://git.savannah.gnu.org/cgit//commit/?id=00776702a3b6a407dccb7dc2319e0768ddb2156d


commit 00776702a3b6a407dccb7dc2319e0768ddb2156d
Merge: ea602ba 7e40169
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Nov 4 08:36:47 2010 +0100

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=ea602ba0a49444bda2768a6735fcc2ab4ac5d7f5


commit ea602ba0a49444bda2768a6735fcc2ab4ac5d7f5
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 31 19:11:00 2010 +0100

    Rename to baseURL, since that's what it is.

diff --git a/gui/Player.cpp b/gui/Player.cpp
index 18eeb98..e6121b8 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -226,11 +226,13 @@ Player::load_movie()
     }
 
     try {
-        if ( _infile == "-" ) {
+        if (_infile == "-") {
+            log_debug("Using filno");
             std::auto_ptr<IOChannel> in (
                 noseek_fd_adapter::make_stream(fileno(stdin)));
             md = MovieFactory::makeMovie(in, _url, *_runResources, false);
-        } else {
+        }
+        else {
             URL url(_infile);
             if ( url.protocol() == "file" ) {
                 std::string path = url.path();
@@ -249,12 +251,13 @@ Player::load_movie()
             md = MovieFactory::makeMovie(url, *_runResources, _url.c_str(),
                     false);
         }
-    } catch (const GnashException& er) {
+    }
+    catch (const GnashException& er) {
         std::cerr << er.what() << std::endl;
         md = NULL;
     }
 
-    if ( ! md ) {
+    if (!md) {
         fprintf(stderr, "Could not load movie '%s'\n", _infile.c_str());
         return NULL;
     }
@@ -517,7 +520,7 @@ Player::run(int argc, char* argv[], const std::string& 
infile,
 
         // Use default if filename is empty.
         if (_screenshotFile.empty()) {
-            URL url(_runResources->streamProvider().originalURL());
+            URL url(_runResources->streamProvider().baseURL());
             std::string::size_type p = url.path().rfind('/');
             const std::string& name = (p == std::string::npos) ? url.path() :
                 url.path().substr(p + 1);
diff --git a/gui/gui.cpp b/gui/gui.cpp
index a97a5e0..c377ee0 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -1025,7 +1025,7 @@ Gui::takeScreenShot()
     if (!_screenShotter.get()) {
         // If no ScreenShotter exists, none was requested at startup.
         // We use a default filename pattern.
-        URL url(_runResources.streamProvider().originalURL());
+        URL url(_runResources.streamProvider().baseURL());
         std::string::size_type p = url.path().rfind('/');
         const std::string& name = (p == std::string::npos) ? url.path() :
             url.path().substr(p + 1);
diff --git a/libbase/StreamProvider.h b/libbase/StreamProvider.h
index 4630d19..30f04fd 100644
--- a/libbase/StreamProvider.h
+++ b/libbase/StreamProvider.h
@@ -114,8 +114,8 @@ public:
     //
     /// TODO: drop this if possible and handle all resolution in
     /// this class.
-    const URL& originalURL() const {
-        return _original;
+    const URL& baseURL() const {
+        return _base;
     }
 
 private:
diff --git a/libcore/MovieClip.cpp b/libcore/MovieClip.cpp
index 0afc117..2874869 100644
--- a/libcore/MovieClip.cpp
+++ b/libcore/MovieClip.cpp
@@ -1924,7 +1924,7 @@ MovieClip::loadVariables(const std::string& urlstr,
     // (down by getStream, that is)
     
     const movie_root& mr = stage();
-    URL url(urlstr, mr.runResources().streamProvider().originalURL());
+    URL url(urlstr, mr.runResources().streamProvider().baseURL());
 
     std::string postdata;
     
diff --git a/libcore/MovieLoader.cpp b/libcore/MovieLoader.cpp
index 0e58097..cb02d6d 100644
--- a/libcore/MovieLoader.cpp
+++ b/libcore/MovieLoader.cpp
@@ -434,7 +434,7 @@ MovieLoader::loadMovie(const std::string& urlstr,
 
     /// URL security is checked in StreamProvider::getStream() down the
     /// chain.
-    URL url(urlstr, _movieRoot.runResources().streamProvider().originalURL());
+    URL url(urlstr, _movieRoot.runResources().streamProvider().baseURL());
 
     /// If the method is MovieClip::METHOD_NONE, we send no data.
     if (method == MovieClip::METHOD_GET)
diff --git a/libcore/asobj/LoadableObject.cpp b/libcore/asobj/LoadableObject.cpp
index 4a66341..896ec7d 100644
--- a/libcore/asobj/LoadableObject.cpp
+++ b/libcore/asobj/LoadableObject.cpp
@@ -341,7 +341,7 @@ loadableobject_sendAndLoad(const fn_call& fn)
 
     const RunResources& ri = getRunResources(*obj);
 
-    URL url(urlstr, ri.streamProvider().originalURL());
+    URL url(urlstr, ri.streamProvider().baseURL());
 
     std::auto_ptr<IOChannel> str;
 
@@ -435,7 +435,7 @@ loadableobject_load(const fn_call& fn)
 
     const RunResources& ri = getRunResources(*obj);
 
-    URL url(urlstr, ri.streamProvider().originalURL());
+    URL url(urlstr, ri.streamProvider().baseURL());
 
     // Checks whether access is allowed.
     std::auto_ptr<IOChannel> str(ri.streamProvider().getStream(url));
diff --git a/libcore/asobj/LocalConnection_as.cpp 
b/libcore/asobj/LocalConnection_as.cpp
index a2f96d4..509be3f 100644
--- a/libcore/asobj/LocalConnection_as.cpp
+++ b/libcore/asobj/LocalConnection_as.cpp
@@ -935,7 +935,7 @@ std::string
 getDomain(as_object& o)
 {
     
-    const URL& url = getRunResources(o).streamProvider().originalURL();
+    const URL& url = getRunResources(o).streamProvider().baseURL();
 
     if (url.hostname().empty()) {
         return "localhost";
diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 41266c4..6f50636 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -339,7 +339,7 @@ public:
             // TODO: check where it gets these data from.
             o->init_member("flashVer", getVM(_nc.owner()).getPlayerVersion(),
                     flags);
-            o->init_member("swfUrl", r.streamProvider().originalURL().str(),
+            o->init_member("swfUrl", r.streamProvider().baseURL().str(),
                     flags);
             o->init_member("tcUrl", _url.str(), flags);
 
@@ -434,7 +434,7 @@ std::string
 NetConnection_as::validateURL() const
 {
     const RunResources& r = getRunResources(owner());
-    URL uri(_uri, r.streamProvider().originalURL());
+    URL uri(_uri, r.streamProvider().baseURL());
 
     std::string uriStr(uri.str());
     assert(uriStr.find("://") != std::string::npos);
@@ -494,7 +494,7 @@ NetConnection_as::connect(const std::string& uri)
     }
     
     const RunResources& r = getRunResources(owner());
-    URL url(_uri, r.streamProvider().originalURL());
+    URL url(_uri, r.streamProvider().baseURL());
 
     if (!r.streamProvider().allow(url)) {
         log_security(_("Gnash is not allowed to connect " "to %s"), url);
@@ -592,7 +592,7 @@ NetConnection_as::getStream(const std::string& name)
     // which should always be null in this case.
     const RcInitFile& rcfile = RcInitFile::getDefaultInstance();
 
-    URL url(name, streamProvider.originalURL());
+    URL url(name, streamProvider.baseURL());
 
     return streamProvider.getStream(url, rcfile.saveStreamingMedia());
 
diff --git a/libcore/asobj/SharedObject_as.cpp 
b/libcore/asobj/SharedObject_as.cpp
index db87da1..fb70a67 100644
--- a/libcore/asobj/SharedObject_as.cpp
+++ b/libcore/asobj/SharedObject_as.cpp
@@ -424,7 +424,7 @@ SharedObjectLibrary::SharedObjectLibrary(VM& vm)
     // by the 'base' attribute of OBJECT or EMBED tags trough
     // -P base=xxx
     const movie_root& mr = _vm.getRoot();
-    const URL& url = mr.runResources().streamProvider().originalURL();
+    const URL& url = mr.runResources().streamProvider().baseURL();
 
     // Remember the hostname of our SWF URL. This can be empty if loaded
     // from the filesystem
@@ -506,7 +506,7 @@ SharedObjectLibrary::getLocal(const std::string& objName,
 
         const movie_root& mr = _vm.getRoot();
 
-        const URL& swfURL = mr.runResources().streamProvider().originalURL();
+        const URL& swfURL = mr.runResources().streamProvider().baseURL();
         // The specified root may or may not have a domain. If it doesn't,
         // this constructor will add the SWF's domain.
         URL localPath(root, swfURL);
diff --git a/libcore/asobj/Sound_as.cpp b/libcore/asobj/Sound_as.cpp
index f125c59..88c1d51 100644
--- a/libcore/asobj/Sound_as.cpp
+++ b/libcore/asobj/Sound_as.cpp
@@ -528,7 +528,7 @@ Sound_as::loadSound(const std::string& file, bool streaming)
     _startTime=0;
 
     const RunResources& rr = getRunResources(owner());
-    URL url(file, rr.streamProvider().originalURL());
+    URL url(file, rr.streamProvider().baseURL());
 
     const RcInitFile& rcfile = RcInitFile::getDefaultInstance();
 
diff --git a/libcore/asobj/flash/external/ExternalInterface_as.cpp 
b/libcore/asobj/flash/external/ExternalInterface_as.cpp
index eee1961..640f4e4 100644
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp
@@ -324,7 +324,7 @@ externalinterface_available(const fn_call& fn)
       case movie_root::SCRIPT_ACCESS_SAME_DOMAIN:
       {
           const RunResources& r = m.runResources();
-          const std::string& baseurl = r.streamProvider().originalURL().str();
+          const std::string& baseurl = r.streamProvider().baseURL().str();
           char hostname[MAXHOSTNAMELEN];
           std::memset(hostname, 0, MAXHOSTNAMELEN);
           
diff --git a/libcore/movie_root.cpp b/libcore/movie_root.cpp
index f8024a3..7d243d7 100644
--- a/libcore/movie_root.cpp
+++ b/libcore/movie_root.cpp
@@ -2099,7 +2099,7 @@ movie_root::getURL(const std::string& urlstr, const 
std::string& target,
         /// If there is no hosting application, call the URL launcher. For
         /// safety, we resolve the URL against the base URL for this run.
         /// The data is not sent at all.
-        URL url(urlstr, _runResources.streamProvider().originalURL());
+        URL url(urlstr, _runResources.streamProvider().baseURL());
 
         gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
         std::string command = rcfile.getURLOpenerFormat();
diff --git a/libcore/movie_root.h b/libcore/movie_root.h
index 76d7abc..2eaea7a 100644
--- a/libcore/movie_root.h
+++ b/libcore/movie_root.h
@@ -1011,7 +1011,7 @@ private:
     const RunResources& _runResources; 
 
     /// This initializes a SharedObjectLibrary, which requires 
-    /// _originalURL, so that must be initialized first.
+    /// _baseURL, so that must be initialized first.
     VM _vm;
 
     /// Registered Interface command handler, if any
diff --git a/libcore/swf/ImportAssetsTag.h b/libcore/swf/ImportAssetsTag.h
index 10634b6..9eadae8 100644
--- a/libcore/swf/ImportAssetsTag.h
+++ b/libcore/swf/ImportAssetsTag.h
@@ -80,7 +80,7 @@ private:
         in.read_string(source_url);
 
         // Resolve relative urls against baseurl
-        URL abs_url(source_url, r.streamProvider().originalURL());
+        URL abs_url(source_url, r.streamProvider().baseURL());
 
         unsigned char import_version = 0;
 

http://git.savannah.gnu.org/cgit//commit/?id=55e712d5141cd67d895774aeb62f57f1e2badd94


commit 55e712d5141cd67d895774aeb62f57f1e2badd94
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 31 17:40:09 2010 +0100

    More changes for old ming versions.

diff --git a/testsuite/misc-ming.all/BitmapSmoothingTest.c 
b/testsuite/misc-ming.all/BitmapSmoothingTest.c
index 90b3f39..2a33405 100644
--- a/testsuite/misc-ming.all/BitmapSmoothingTest.c
+++ b/testsuite/misc-ming.all/BitmapSmoothingTest.c
@@ -45,6 +45,7 @@ main(int argc, char **argv)
        SWFFont font;
        SWFMovieClip dejagnuclip;
        char outputFilename[256];
+    FILE* imgfile;
 
        if ( argc < 2 ) {
                fprintf(stderr, "Usage: %s <swf_version>\n", argv[0]);
@@ -71,13 +72,18 @@ main(int argc, char **argv)
        /****************************************************
        * Create filled shapes mc
        ****************************************************/
-       in = newSWFInput_filename(MEDIADIR"/vstroke.png");
-       if ( ! in ) {
-               return EXIT_FAILURE;
-       }
-
+    imgfile = fopen(MEDIADIR"/vstroke.png", "rb");
+    if (!imgfile) {
+        fprintf(stderr, "Failed to open bitmap file");
+        return EXIT_FAILURE;
+    }
+
+    // Note that recent ming version have the more convenient
+    // newSWFInput_filename() function, but we want to support
+    // older versions.
+    in = newSWFInput_file(imgfile);
        bitmap = newSWFBitmap_fromInput(in);
-       if ( ! bitmap ) {
+       if (!bitmap) {
                return EXIT_FAILURE;
        }
 
@@ -127,6 +133,8 @@ main(int argc, char **argv)
 
        SWFMovie_save(mo, outputFilename);
 
+    fclose(imgfile);
+
        return EXIT_SUCCESS;
 }
 
diff --git a/testsuite/misc-ming.all/LoadBitmapTest.c 
b/testsuite/misc-ming.all/LoadBitmapTest.c
index 936ed97..513e776 100644
--- a/testsuite/misc-ming.all/LoadBitmapTest.c
+++ b/testsuite/misc-ming.all/LoadBitmapTest.c
@@ -42,6 +42,7 @@ main(int argc, char** argv)
     SWFMovieClip dejagnuclip;
     SWFBitmap bp;
     SWFInput inp;
+    FILE* imgfile;
 
     if (argc > 1) mediadir = argv[1];
     else {
@@ -72,8 +73,20 @@ main(int argc, char** argv)
     strcpy(path, mediadir);
     strcat(path, file);
 
-    inp = newSWFInput_filename(path);
-    bp = (SWFBitmap)newSWFJpegBitmap_fromInput(inp);
+    imgfile = fopen(path, "rb");
+    if (!imgfile) {
+        fprintf(stderr, "Failed to open bitmap file");
+        return EXIT_FAILURE;
+    }
+
+    // Note that recent ming version have the more convenient
+    // newSWFInput_filename() function, but we want to support
+    // older versions.
+    inp = newSWFInput_file(imgfile);
+       bp = newSWFBitmap_fromInput(inp);
+       if (!bp) {
+               return EXIT_FAILURE;
+       }
     SWFMovie_addExport(mo, (SWFBlock)bp, "img1");
 
     SWFMovie_writeExports(mo);
@@ -160,5 +173,7 @@ main(int argc, char** argv)
     puts("Saving " OUTPUT_FILENAME);
     SWFMovie_save(mo, OUTPUT_FILENAME);
 
+    fclose(imgfile);
+
     return EXIT_SUCCESS;
 }

http://git.savannah.gnu.org/cgit//commit/?id=9bab924d3bedefb7be78594f28eb882fd0db525c


commit 9bab924d3bedefb7be78594f28eb882fd0db525c
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 31 17:02:41 2010 +0100

    Use older function for old mingers.

diff --git a/testsuite/misc-ming.all/BitmapDataDraw.c 
b/testsuite/misc-ming.all/BitmapDataDraw.c
index 83287d7..083019d 100644
--- a/testsuite/misc-ming.all/BitmapDataDraw.c
+++ b/testsuite/misc-ming.all/BitmapDataDraw.c
@@ -46,6 +46,7 @@ main(int argc, char** argv)
     SWFFillStyle fill;
     SWFBitmap bp;
     SWFInput inp;
+    FILE* imgfile;
 
     if (argc > 1) mediadir = argv[1];
     else {
@@ -242,7 +243,16 @@ main(int argc, char** argv)
     strcpy(path, mediadir);
     strcat(path, file);
 
-    inp = newSWFInput_filename(path);
+    imgfile = fopen(path, "rb");
+    if (!imgfile) {
+        fprintf(stderr, "Failed to open bitmap file");
+        exit(EXIT_FAILURE);
+    }
+
+    // Note that recent ming version have the more convenient
+    // newSWFInput_filename() function, but we want to support
+    // older versions.
+    inp = newSWFInput_file(imgfile);
     bp = (SWFBitmap)newSWFJpegBitmap_fromInput(inp);
     
     // Image clip
@@ -305,5 +315,7 @@ main(int argc, char** argv)
     puts("Saving " OUTPUT_FILENAME);
     SWFMovie_save(mo, OUTPUT_FILENAME);
 
+    fclose(imgfile);
+
     return EXIT_SUCCESS;
 }

http://git.savannah.gnu.org/cgit//commit/?id=3b5da9e765b05155172c231d06d1fe347c7abf30


commit 3b5da9e765b05155172c231d06d1fe347c7abf30
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 31 16:59:46 2010 +0100

    Documentation.

diff --git a/libbase/StreamProvider.h b/libbase/StreamProvider.h
index 34b8c6e..4630d19 100644
--- a/libbase/StreamProvider.h
+++ b/libbase/StreamProvider.h
@@ -103,17 +103,17 @@ public:
     /// Check whether access to a URL is allowed
     //
     /// This is used by the core to check whether a connection can be
-    /// made before trying to make it.
+    /// made before trying to make it. It's useful currently for
+    /// some functions to decide what to return.
     //
     /// @param url      The url to check
     /// @return         true if allowed, false if not.
     bool allow(const URL& url) const;
 
-    /// The genuine original URL used for loading the first SWF.
+    /// The base URL that should be used to resolve all relative URLs.
     //
-    /// This is used to manage access to later URLs.
-    //
-    /// TODO: drop this if possible
+    /// TODO: drop this if possible and handle all resolution in
+    /// this class.
     const URL& originalURL() const {
         return _original;
     }

http://git.savannah.gnu.org/cgit//commit/?id=fd4ac07c55d64c91e186a03ab338352d99c5fdc6


commit fd4ac07c55d64c91e186a03ab338352d99c5fdc6
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 31 16:18:37 2010 +0100

    Pass the original URL to StreamProvider, document what the
    class is, and what it should do in future.

diff --git a/gui/Player.cpp b/gui/Player.cpp
index 0de857c..18eeb98 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -309,7 +309,7 @@ Player::run(int argc, char* argv[], const std::string& 
infile,
     std::auto_ptr<NamingPolicy> np(new IncrementalRename(_baseurl));
 
     /// The StreamProvider uses the actual URL of the loaded movie.
-    boost::shared_ptr<StreamProvider> sp(new StreamProvider(baseURL, np));
+    boost::shared_ptr<StreamProvider> sp(new StreamProvider(_url, baseURL, 
np));
 
     _runResources->setStreamProvider(sp);
 
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 1c41796..a97a5e0 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -37,7 +37,6 @@
 #include "DisplayObject.h"
 #include "GnashEnums.h"
 #include "RunResources.h"
-#include "StreamProvider.h"
 
 #ifdef GNASH_FPS_DEBUG
 #include "ClockTime.h"
diff --git a/gui/pythonmod/gnash-view.cpp b/gui/pythonmod/gnash-view.cpp
index 633e0ef..3569f77 100644
--- a/gui/pythonmod/gnash-view.cpp
+++ b/gui/pythonmod/gnash-view.cpp
@@ -417,7 +417,6 @@ motion_notify_event_cb(GtkWidget */*widget*/, 
GdkEventMotion *event, gpointer da
 static void
 gnash_view_load_movie(GnashView *view, const gchar *uri)
 {
-    GNASH_REPORT_FUNCTION;
 
     gnash::URL url(uri);
 
@@ -427,7 +426,7 @@ gnash_view_load_movie(GnashView *view, const gchar *uri)
 
     std::auto_ptr<gnash::NamingPolicy> np(new gnash::IncrementalRename(url));
     boost::shared_ptr<gnash::StreamProvider> sp(
-           new gnash::StreamProvider(url, np));
+           new gnash::StreamProvider(url, url, np));
     view->run_info->setStreamProvider(sp);
 
     gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
diff --git a/libbase/StreamProvider.cpp b/libbase/StreamProvider.cpp
index a07867b..dd1442c 100644
--- a/libbase/StreamProvider.cpp
+++ b/libbase/StreamProvider.cpp
@@ -36,17 +36,19 @@
 
 namespace gnash {
 
-StreamProvider::StreamProvider(const URL& url, std::auto_ptr<NamingPolicy> np)
+StreamProvider::StreamProvider(const URL& orig, const URL& base,
+        std::auto_ptr<NamingPolicy> np)
     :
     _namingPolicy(np),
-    _url(url)
+    _base(base),
+    _original(orig)
 {
 }
     
 bool
 StreamProvider::allow(const URL& url) const
 {
-    return URLAccessManager::allow(url, _url);
+    return URLAccessManager::allow(url, _original);
 }
 
 std::auto_ptr<IOChannel>
@@ -84,8 +86,7 @@ StreamProvider::getStream(const URL& url, bool 
namedCacheFile) const
                        return stream;
                }
        }
-       else
-       {
+       else {
                if (allow(url)) {
                        stream = NetworkAdapter::makeStream(url.str(), 
                     namedCacheFile ? namingPolicy()(url) : "");
@@ -102,10 +103,8 @@ StreamProvider::getStream(const URL& url, const 
std::string& postdata,
         const
 {
 
-    if (url.protocol() == "file")
-    {
-        if (!headers.empty())
-        {
+    if (url.protocol() == "file") {
+        if (!headers.empty()) {
             log_error("Request Headers discarded while getting stream "
                     "from file: uri");
         }
@@ -128,10 +127,8 @@ StreamProvider::getStream(const URL& url, const 
std::string& postdata,
 
     std::auto_ptr<IOChannel> stream;
 
-       if (url.protocol() == "file")
-       {
-        if (!postdata.empty())
-        {    
+       if (url.protocol() == "file") {
+        if (!postdata.empty()) {    
                    log_error(_("POST data discarded while getting a stream "
                         "from file: uri"));
         }
@@ -141,8 +138,7 @@ StreamProvider::getStream(const URL& url, const 
std::string& postdata,
                        stream = makeFileChannel(newin, false);
                        return stream;
                }
-               else
-               {
+               else {
                        if (!allow(url)) return stream;
 
                        FILE *newin = std::fopen(path.c_str(), "rb");
@@ -153,8 +149,7 @@ StreamProvider::getStream(const URL& url, const 
std::string& postdata,
                        return stream;
                }
        }
-       else
-       {
+       else {
                if (allow(url)) {
                        stream = NetworkAdapter::makeStream(url.str(), postdata,
                     namedCacheFile ? namingPolicy()(url) : "");
diff --git a/libbase/StreamProvider.h b/libbase/StreamProvider.h
index 5fdbca3..34b8c6e 100644
--- a/libbase/StreamProvider.h
+++ b/libbase/StreamProvider.h
@@ -35,13 +35,29 @@ namespace gnash {
 
 namespace gnash {
 
-/// Provide IOChannel streams for network or filesystem resources
+/// A StreamProvider makes IOChannels available to the core on request.
+//
+/// The current functions of this class are:
+/// 1. Inform users whether a connection to a certain URL is allowed.
+/// 2. Make a connection and return an IOChannel (this performs a separate
+///    access check).
+///
+/// The class should in future also:
+/// 3. Take relative URLs and resolve them against the base URL.
+//
+/// TODO: this class should become an abstract interface.
 class DSOEXPORT StreamProvider
 {
-
 public:
 
-       StreamProvider(const URL& url, std::auto_ptr<NamingPolicy> = 
+    /// Construct a StreamProvider
+    //
+    /// @param original     The original URL, used to decide whether to allow
+    ///                     connections.
+    /// @param base         The base URL, used to resolve URLs.
+    /// @param np           A policy to decide the name of cached files.
+       StreamProvider(const URL& original, const URL& base,
+            std::auto_ptr<NamingPolicy> np =
             std::auto_ptr<NamingPolicy>(new NamingPolicy));
 
        virtual ~StreamProvider() {}
@@ -50,7 +66,6 @@ public:
        //
        /// On error NULL is returned
        /// Derive from this for a CachingStreamProvider
-       ///
        virtual std::auto_ptr<IOChannel> getStream(const URL& url,
             bool namedCacheFile = false) const;
 
@@ -61,13 +76,8 @@ public:
        /// On error NULL is returned
        /// Derive from this for a CachingStreamProvider
        ///
-       /// @param url
-       ///     The url to post to.
-       ///
-       /// @param postdata
-       ///     Post data in url-encoded form.
-       ///
-       ///
+       /// @param url      The url to post to.
+       /// @param postdata Post data in url-encoded form.
        virtual std::auto_ptr<IOChannel> getStream(const URL& url,
             const std::string& postdata, bool namedCacheFile = false) const;
        
@@ -90,14 +100,22 @@ public:
         return *_namingPolicy;
     }
 
-    /// Whether to allow access to a certain URL.
+    /// Check whether access to a URL is allowed
+    //
+    /// This is used by the core to check whether a connection can be
+    /// made before trying to make it.
+    //
+    /// @param url      The url to check
+    /// @return         true if allowed, false if not.
     bool allow(const URL& url) const;
 
     /// The genuine original URL used for loading the first SWF.
     //
     /// This is used to manage access to later URLs.
+    //
+    /// TODO: drop this if possible
     const URL& originalURL() const {
-        return _url;
+        return _original;
     }
 
 private:
@@ -105,7 +123,9 @@ private:
     /// The current naming policy for cache files.
     std::auto_ptr<NamingPolicy> _namingPolicy;
 
-    const URL _url;
+    const URL _base;
+
+    const URL _original;
 
 };
 
diff --git a/libcore/Makefile.am b/libcore/Makefile.am
index 9d89b14..8634053 100644
--- a/libcore/Makefile.am
+++ b/libcore/Makefile.am
@@ -54,7 +54,6 @@ libgnashcore_la_SOURCES = \
        BitmapMovie.cpp \
        Property.cpp \
        PropertyList.cpp \
-       URLAccessManager.cpp \
        SystemClock.cpp \
        ClassHierarchy.cpp \
        as_environment.cpp \
@@ -142,7 +141,6 @@ libgnashcore_la_SOURCES += \
 endif
 
 noinst_HEADERS = \
-       URLAccessManager.h \
        VirtualClock.h \
        SystemClock.h \
        ClassHierarchy.h \
diff --git a/libcore/RunResources.h b/libcore/RunResources.h
index 4dcbde7..24161a8 100644
--- a/libcore/RunResources.h
+++ b/libcore/RunResources.h
@@ -22,20 +22,11 @@
 
 #include <string>
 #include <boost/shared_ptr.hpp>
-
-namespace gnash {
-    class Renderer;
-    class StreamProvider;
-    namespace SWF {
-        class TagLoadersTable;
-    }
-    namespace sound {
-        class sound_handler;
-    }
-    namespace media {
-        class MediaHandler;
-    }
-}
+#include "StreamProvider.h"
+#include "Renderer.h"
+#include "sound_handler.h"
+#include "MediaHandler.h"
+#include "TagLoadersTable.h"
 
 namespace gnash {
 
diff --git a/libcore/URLAccessManager.cpp b/libcore/URLAccessManager.cpp
deleted file mode 100644
index 8740f08..0000000
--- a/libcore/URLAccessManager.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-// 
-//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-//   Foundation, Inc
-// 
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-#include "URLAccessManager.h"
-#include "URL.h"
-#include "log.h"
-#include "StringPredicates.h" 
-#include "rc.h" // for rcfile
-#include "GnashSystemNetHeaders.h"
-
-#include <cerrno> 
-#include <iostream>
-#include <algorithm> // for find / find_if
-#include <cstring> // for strerror
-#include <cstdio>
-#include <map>
-#include <string>
-#include <vector>
-#include <cassert>
-
-namespace gnash {
-namespace URLAccessManager {
-
-/// Possible access policies for URLs
-enum AccessPolicy {    
-
-       /// Forbid access 
-       BLOCK,
-
-       /// Allow access
-       GRANT
-};
-
-const char*
-accessPolicyString(AccessPolicy policy)
-{
-       switch(policy)
-       {
-               case BLOCK:
-                       return "BLOCKED";
-               case GRANT:
-                       return "GRANTED";
-               default:
-                       return "UNKNOWN";
-       }
-}
-
-// The default AccessPolicy when prompting user is not possible
-// (this happens when input is not a tty, at the moment)
-//static AccessPolicy defaultAccessPolicy = GRANT;
-
-/// A cache of AccessPolicy defined for URLs
-typedef std::map<std::string, AccessPolicy> AccessPolicyCache;
-
-/// A global AccessPolicyCache
-static AccessPolicyCache policyCache;
-
-// check host against black/white lists
-// return true if we allow load from host, false otherwise
-// it is assumed localhost/localdomain was already checked
-static bool
-host_check_blackwhite_lists(const std::string& host)
-{
-       using std::vector;
-       using std::string;
-
-       RcInitFile& rcfile = RcInitFile::getDefaultInstance();
-
-
-       const std::vector<std::string>& whitelist = rcfile.getWhiteList();
-       if (!whitelist.empty()) {
-               // TODO: case-insensitive matching ? 
-        std::vector<std::string>::const_iterator it =
-            std::find(whitelist.begin(), whitelist.end(), host);
-               if (it != whitelist.end()) {
-                       log_security(_("Load from host %s granted 
(whitelisted)"),
-                               host);
-                       return true;
-               }
-
-               // if there is a whitelist, anything NOT listed is denied
-               log_security(_("Load from host %s forbidden "
-                       "(not in non-empty whitelist)"),
-                       host);
-
-               return false;
-       }
-
-    const std::vector<std::string>& blacklist = rcfile.getBlackList();
-
-       // TODO: case-insensitive matching ? 
-    std::vector<std::string>::const_iterator it =
-        std::find(blacklist.begin(), blacklist.end(), host);
-
-       if (it != blacklist.end()) {
-               log_security(_("Load from host %s forbidden (blacklisted)"),
-                       host);
-               return false;
-       }
-
-       log_security(_("Load from host %s granted (default)"), host);
-       return true;
-}
-
-static bool
-pathIsUnderDir(const std::string& path, const std::string& dir)
-{
-    size_t dirLen = dir.length();
-    if ( dirLen > path.length() ) return false; // can't contain it, right ?
-
-    // Path must be equal to dir for the whole dir length
-    //
-    // TODO: this is pretty lame, can do better with some normalization
-    //       we'd need a generic splitPathInComponents.. maybe as a static
-    //       public method of gnash::URL ?
-    //
-    if ( path.compare(0, dirLen, dir) ) return false;
-
-    return true;
-}
-
-/// Return true if we allow load of the local resource, false otherwise.
-//
-static bool
-local_check(const std::string& path, const URL& baseUrl)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    assert( ! path.empty() );
-
-    // Don't allow local access if starting movie is a network resource.
-   if (baseUrl.protocol() != "file") {
-      log_security(_("Load of file %s forbidden"
-          " (starting url %s is not a local resource)"),
-          path, baseUrl.str());
-      return false;
-   }
-
-    RcInitFile& rcfile = RcInitFile::getDefaultInstance();
-    
-    typedef RcInitFile::PathList PathList;
-    const PathList& sandbox = rcfile.getLocalSandboxPath();
-
-    for (PathList::const_iterator i=sandbox.begin(), e=sandbox.end();
-            i!=e; ++i)
-    {
-        const std::string& dir = *i;
-        if ( pathIsUnderDir(path, dir) ) 
-        {
-            log_security(_("Load of file %s granted (under local sandbox %s)"),
-                path, dir);
-            return true;
-        }
-    }
-
-    // TODO: dump local sandboxes here ? (or maybe send the info to the GUI 
properties
-    //       view
-    log_security(_("Load of file %s forbidden (not under local sandboxes)"),
-        path);
-    return false;
-
-}
-
-/// Return true if we allow load from host, false otherwise.
-//
-/// This function will check for localhost/localdomain (if requested)
-/// and finally call host_check_blackwhitelists
-/// 
-static bool
-host_check(const std::string& host)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    //log_security("Checking security of host: %s", host.c_str());
-    
-    assert( ! host.empty() );
-
-    RcInitFile& rcfile = RcInitFile::getDefaultInstance();
-    
-    bool check_domain = rcfile.useLocalDomain();
-    bool check_localhost = rcfile.useLocalHost();
-
-    // Don't bother gettin hostname if we're not going to need it
-    if ( ! ( check_domain  || check_localhost ) )
-    {
-        return host_check_blackwhite_lists(host);
-    }
-
-    //
-    // Get hostname
-    //
-
-    #define MAXHOSTNAMELEN 200
-    char name[MAXHOSTNAMELEN];
-    if (::gethostname(name, MAXHOSTNAMELEN) == -1)
-    {
-        // FIXME: strerror is NOT thread-safe
-        log_error(_("gethostname failed: %s"), std::strerror(errno)); 
-        return host_check_blackwhite_lists(host);
-    }
-    // From GETHOSTNAME(2): 
-    // In case the NUL-terminated hostname does not fit,
-    // no  error is returned, but the hostname is truncated. It is unspecified
-    // whether the truncated hostname will be NUL-terminated.
-    name[MAXHOSTNAMELEN - 1] = '\0'; // unlikely, still worth making sure...
-
-    // ok, let's use std::strings... we're a C++ program after all !
-    std::string hostname(name); // the hostname
-    std::string domainname;     // the domainname
-
-    // Split hostname/domainname or take it all as an hostname if
-    // no dot is found
-    std::string::size_type dotloc = hostname.find('.', 0);
-    if ( dotloc != std::string::npos ) {
-        domainname = hostname.substr(dotloc+1);
-        hostname.erase(dotloc);
-    }
-
-    if ( check_domain && domainname != host ) {
-       log_security(_("Load from host %s forbidden (not in the local domain)"),
-               host);
-        return false;
-       }
-    
-    if ( check_localhost && hostname != host ) {
-       log_security(_("Load from host %s forbidden (not on the local host)"),
-               host);
-        return false;
-    }
-
-    return host_check_blackwhite_lists(host);
-
-}
-
-bool
-allowHost(const std::string& host)
-{
-       if (host.size() == 0) {
-               return true;
-       }
-       return host_check(host);
-}
-
-bool
-allowXMLSocket(const std::string& host, short port)
-{
-    if (port < 1024) {
-        log_security("Attempt to connect to disallowed port %s", port);
-        return false;
-    }
-       return allowHost(host);
-}
-
-
-bool
-allow(const URL& url, const URL& baseurl)
-{
-       log_security(_("Checking security of URL '%s'"), url);
-
-       // We might reintroduce use of an AccessPolicy cache
-
-       std::string host = url.hostname();
-
-       // Local resources can be accessed only if they are
-       // in a directory listed as local sandbox
-       if (host.size() == 0)
-       {
-               if (url.protocol() != "file")
-        {
-            log_error(_("Network connection without hostname requested"));
-            return false;
-        }
-               return local_check(url.path(), baseurl);
-       }
-       return host_check(host);
-}
-
-
-} // AccessManager
-} // namespace gnash
-
diff --git a/libcore/URLAccessManager.h b/libcore/URLAccessManager.h
deleted file mode 100644
index 77478cb..0000000
--- a/libcore/URLAccessManager.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// 
-//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-//   Foundation, Inc
-// 
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-#ifndef GNASH_URLACCESSMANAGER_H
-#define GNASH_URLACCESSMANAGER_H
-
-#include <string>
-
-// Forward declarations
-namespace gnash {
-       class URL;
-}
-
-namespace gnash {
-
-/// Manage a list of URL access configuration
-// stuff for an URLAccessManager
-namespace URLAccessManager {
-
-/// Return true if access to given url is allowed, false otherwise.
-//
-/// Will use rc file for whitelist/blacklist and localSandbox.
-///
-/// @param url
-///   The url to check
-///
-/// @param baseurl
-///   The originating url, only used for local urls and only
-///   for protocol checking (ie: a non-local originating url
-///   will not be allowed to load a local url)
-///
-bool allow(const URL& url, const URL& baseurl);
-
-//bool allowHost(const std::string& str);
-
-// Used by XMLSocket::connect (and others?)
-bool allowXMLSocket(const std::string& str, short port);
-
-} // AccessManager
-
-} // namespace gnash
-
-#endif // _GNASH_URLACCESSMANAGER_H
diff --git a/testsuite/MovieTester.cpp b/testsuite/MovieTester.cpp
index ee581ff..3519070 100644
--- a/testsuite/MovieTester.cpp
+++ b/testsuite/MovieTester.cpp
@@ -90,7 +90,7 @@ MovieTester::MovieTester(const std::string& url)
     
     _runResources->setTagLoaders(loaders);
     
-    boost::shared_ptr<StreamProvider> sp(new StreamProvider(url));
+    boost::shared_ptr<StreamProvider> sp(new StreamProvider(url, url));
 
     _runResources->setStreamProvider(sp);
 
diff --git a/testsuite/libcore.all/AsValueTest.cpp 
b/testsuite/libcore.all/AsValueTest.cpp
index bf46fd5..7a4f4ff 100644
--- a/testsuite/libcore.all/AsValueTest.cpp
+++ b/testsuite/libcore.all/AsValueTest.cpp
@@ -98,8 +98,10 @@ main(int argc, char *argv[])
     // Initialize gnash lib
     
     RunResources runResources;
+
+    const URL url("");
     runResources.setStreamProvider(
-            boost::shared_ptr<StreamProvider>(new StreamProvider(URL(""))));
+            boost::shared_ptr<StreamProvider>(new StreamProvider(url, url)));
 
     // Create a bogus movie with swf version 7 support
     movie_definition* md = new DummyMovieDefinition(runResources, 7);
diff --git a/testsuite/libcore.all/DisplayListTest.cpp 
b/testsuite/libcore.all/DisplayListTest.cpp
index d7e1c03..2efdc18 100644
--- a/testsuite/libcore.all/DisplayListTest.cpp
+++ b/testsuite/libcore.all/DisplayListTest.cpp
@@ -51,8 +51,9 @@ main(int /*argc*/, char** /*argv*/)
     // Initialize gnash lib
     
     RunResources ri;
+    const URL url("");
     ri.setStreamProvider(
-            boost::shared_ptr<StreamProvider>(new StreamProvider(URL(""))));
+            boost::shared_ptr<StreamProvider>(new StreamProvider(url, url)));
     
     // Initialize a VM
     boost::intrusive_ptr<movie_definition> md5(new DummyMovieDefinition(ri, 
5));
diff --git a/testsuite/libcore.all/PropertyListTest.cpp 
b/testsuite/libcore.all/PropertyListTest.cpp
index 8add512..e3b8c12 100644
--- a/testsuite/libcore.all/PropertyListTest.cpp
+++ b/testsuite/libcore.all/PropertyListTest.cpp
@@ -67,8 +67,9 @@ main(int /*argc*/, char** /*argv*/)
 
     // We don't care about the base URL.
     RunResources runResources;
+    const URL url("");
     runResources.setStreamProvider(
-            boost::shared_ptr<StreamProvider>(new StreamProvider(URL(""))));
+            boost::shared_ptr<StreamProvider>(new StreamProvider(url, url)));
        
     boost::intrusive_ptr<movie_definition> md5(
             new DummyMovieDefinition(runResources, 5));
diff --git a/utilities/processor.cpp b/utilities/processor.cpp
index 3d3bd73..0782b33 100644
--- a/utilities/processor.cpp
+++ b/utilities/processor.cpp
@@ -373,7 +373,7 @@ main(int argc, char *argv[])
         runResources.setSoundHandler(soundHandler);
         runResources.setMediaHandler(mediaHandler);
         runResources.setTagLoaders(loaders);
-        boost::shared_ptr<StreamProvider> sp(new StreamProvider(*i));
+        boost::shared_ptr<StreamProvider> sp(new StreamProvider(*i, *i));
         runResources.setStreamProvider(sp);
 
 #ifdef RENDERER_AGG

http://git.savannah.gnu.org/cgit//commit/?id=f45362f1c882353b27773cec5a831b0c7293e799


commit f45362f1c882353b27773cec5a831b0c7293e799
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 31 16:18:28 2010 +0100

    Move URLAccessManager to libbase.

diff --git a/libbase/Makefile.am b/libbase/Makefile.am
index 266d6ea..0fae1dc 100644
--- a/libbase/Makefile.am
+++ b/libbase/Makefile.am
@@ -87,6 +87,7 @@ libgnashbase_la_SOURCES = \
        GC.cpp \
        BitsReader.cpp \
        arg_parser.cpp \
+       URLAccessManager.cpp \
        StreamProvider.cpp \
        $(NULL)
 
@@ -184,6 +185,7 @@ inst_HEADERS = \
        getclocktime.hpp \
        GnashAlgorithm.h \
        GnashFactory.h \
+       URLAccessManager.h \
        StreamProvider.h \
        $(NULL)
 
diff --git a/libbase/URLAccessManager.cpp b/libbase/URLAccessManager.cpp
new file mode 100644
index 0000000..8740f08
--- /dev/null
+++ b/libbase/URLAccessManager.cpp
@@ -0,0 +1,296 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#include "URLAccessManager.h"
+#include "URL.h"
+#include "log.h"
+#include "StringPredicates.h" 
+#include "rc.h" // for rcfile
+#include "GnashSystemNetHeaders.h"
+
+#include <cerrno> 
+#include <iostream>
+#include <algorithm> // for find / find_if
+#include <cstring> // for strerror
+#include <cstdio>
+#include <map>
+#include <string>
+#include <vector>
+#include <cassert>
+
+namespace gnash {
+namespace URLAccessManager {
+
+/// Possible access policies for URLs
+enum AccessPolicy {    
+
+       /// Forbid access 
+       BLOCK,
+
+       /// Allow access
+       GRANT
+};
+
+const char*
+accessPolicyString(AccessPolicy policy)
+{
+       switch(policy)
+       {
+               case BLOCK:
+                       return "BLOCKED";
+               case GRANT:
+                       return "GRANTED";
+               default:
+                       return "UNKNOWN";
+       }
+}
+
+// The default AccessPolicy when prompting user is not possible
+// (this happens when input is not a tty, at the moment)
+//static AccessPolicy defaultAccessPolicy = GRANT;
+
+/// A cache of AccessPolicy defined for URLs
+typedef std::map<std::string, AccessPolicy> AccessPolicyCache;
+
+/// A global AccessPolicyCache
+static AccessPolicyCache policyCache;
+
+// check host against black/white lists
+// return true if we allow load from host, false otherwise
+// it is assumed localhost/localdomain was already checked
+static bool
+host_check_blackwhite_lists(const std::string& host)
+{
+       using std::vector;
+       using std::string;
+
+       RcInitFile& rcfile = RcInitFile::getDefaultInstance();
+
+
+       const std::vector<std::string>& whitelist = rcfile.getWhiteList();
+       if (!whitelist.empty()) {
+               // TODO: case-insensitive matching ? 
+        std::vector<std::string>::const_iterator it =
+            std::find(whitelist.begin(), whitelist.end(), host);
+               if (it != whitelist.end()) {
+                       log_security(_("Load from host %s granted 
(whitelisted)"),
+                               host);
+                       return true;
+               }
+
+               // if there is a whitelist, anything NOT listed is denied
+               log_security(_("Load from host %s forbidden "
+                       "(not in non-empty whitelist)"),
+                       host);
+
+               return false;
+       }
+
+    const std::vector<std::string>& blacklist = rcfile.getBlackList();
+
+       // TODO: case-insensitive matching ? 
+    std::vector<std::string>::const_iterator it =
+        std::find(blacklist.begin(), blacklist.end(), host);
+
+       if (it != blacklist.end()) {
+               log_security(_("Load from host %s forbidden (blacklisted)"),
+                       host);
+               return false;
+       }
+
+       log_security(_("Load from host %s granted (default)"), host);
+       return true;
+}
+
+static bool
+pathIsUnderDir(const std::string& path, const std::string& dir)
+{
+    size_t dirLen = dir.length();
+    if ( dirLen > path.length() ) return false; // can't contain it, right ?
+
+    // Path must be equal to dir for the whole dir length
+    //
+    // TODO: this is pretty lame, can do better with some normalization
+    //       we'd need a generic splitPathInComponents.. maybe as a static
+    //       public method of gnash::URL ?
+    //
+    if ( path.compare(0, dirLen, dir) ) return false;
+
+    return true;
+}
+
+/// Return true if we allow load of the local resource, false otherwise.
+//
+static bool
+local_check(const std::string& path, const URL& baseUrl)
+{
+//    GNASH_REPORT_FUNCTION;
+
+    assert( ! path.empty() );
+
+    // Don't allow local access if starting movie is a network resource.
+   if (baseUrl.protocol() != "file") {
+      log_security(_("Load of file %s forbidden"
+          " (starting url %s is not a local resource)"),
+          path, baseUrl.str());
+      return false;
+   }
+
+    RcInitFile& rcfile = RcInitFile::getDefaultInstance();
+    
+    typedef RcInitFile::PathList PathList;
+    const PathList& sandbox = rcfile.getLocalSandboxPath();
+
+    for (PathList::const_iterator i=sandbox.begin(), e=sandbox.end();
+            i!=e; ++i)
+    {
+        const std::string& dir = *i;
+        if ( pathIsUnderDir(path, dir) ) 
+        {
+            log_security(_("Load of file %s granted (under local sandbox %s)"),
+                path, dir);
+            return true;
+        }
+    }
+
+    // TODO: dump local sandboxes here ? (or maybe send the info to the GUI 
properties
+    //       view
+    log_security(_("Load of file %s forbidden (not under local sandboxes)"),
+        path);
+    return false;
+
+}
+
+/// Return true if we allow load from host, false otherwise.
+//
+/// This function will check for localhost/localdomain (if requested)
+/// and finally call host_check_blackwhitelists
+/// 
+static bool
+host_check(const std::string& host)
+{
+//    GNASH_REPORT_FUNCTION;
+
+    //log_security("Checking security of host: %s", host.c_str());
+    
+    assert( ! host.empty() );
+
+    RcInitFile& rcfile = RcInitFile::getDefaultInstance();
+    
+    bool check_domain = rcfile.useLocalDomain();
+    bool check_localhost = rcfile.useLocalHost();
+
+    // Don't bother gettin hostname if we're not going to need it
+    if ( ! ( check_domain  || check_localhost ) )
+    {
+        return host_check_blackwhite_lists(host);
+    }
+
+    //
+    // Get hostname
+    //
+
+    #define MAXHOSTNAMELEN 200
+    char name[MAXHOSTNAMELEN];
+    if (::gethostname(name, MAXHOSTNAMELEN) == -1)
+    {
+        // FIXME: strerror is NOT thread-safe
+        log_error(_("gethostname failed: %s"), std::strerror(errno)); 
+        return host_check_blackwhite_lists(host);
+    }
+    // From GETHOSTNAME(2): 
+    // In case the NUL-terminated hostname does not fit,
+    // no  error is returned, but the hostname is truncated. It is unspecified
+    // whether the truncated hostname will be NUL-terminated.
+    name[MAXHOSTNAMELEN - 1] = '\0'; // unlikely, still worth making sure...
+
+    // ok, let's use std::strings... we're a C++ program after all !
+    std::string hostname(name); // the hostname
+    std::string domainname;     // the domainname
+
+    // Split hostname/domainname or take it all as an hostname if
+    // no dot is found
+    std::string::size_type dotloc = hostname.find('.', 0);
+    if ( dotloc != std::string::npos ) {
+        domainname = hostname.substr(dotloc+1);
+        hostname.erase(dotloc);
+    }
+
+    if ( check_domain && domainname != host ) {
+       log_security(_("Load from host %s forbidden (not in the local domain)"),
+               host);
+        return false;
+       }
+    
+    if ( check_localhost && hostname != host ) {
+       log_security(_("Load from host %s forbidden (not on the local host)"),
+               host);
+        return false;
+    }
+
+    return host_check_blackwhite_lists(host);
+
+}
+
+bool
+allowHost(const std::string& host)
+{
+       if (host.size() == 0) {
+               return true;
+       }
+       return host_check(host);
+}
+
+bool
+allowXMLSocket(const std::string& host, short port)
+{
+    if (port < 1024) {
+        log_security("Attempt to connect to disallowed port %s", port);
+        return false;
+    }
+       return allowHost(host);
+}
+
+
+bool
+allow(const URL& url, const URL& baseurl)
+{
+       log_security(_("Checking security of URL '%s'"), url);
+
+       // We might reintroduce use of an AccessPolicy cache
+
+       std::string host = url.hostname();
+
+       // Local resources can be accessed only if they are
+       // in a directory listed as local sandbox
+       if (host.size() == 0)
+       {
+               if (url.protocol() != "file")
+        {
+            log_error(_("Network connection without hostname requested"));
+            return false;
+        }
+               return local_check(url.path(), baseurl);
+       }
+       return host_check(host);
+}
+
+
+} // AccessManager
+} // namespace gnash
+
diff --git a/libbase/URLAccessManager.h b/libbase/URLAccessManager.h
new file mode 100644
index 0000000..77478cb
--- /dev/null
+++ b/libbase/URLAccessManager.h
@@ -0,0 +1,58 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef GNASH_URLACCESSMANAGER_H
+#define GNASH_URLACCESSMANAGER_H
+
+#include <string>
+
+// Forward declarations
+namespace gnash {
+       class URL;
+}
+
+namespace gnash {
+
+/// Manage a list of URL access configuration
+// stuff for an URLAccessManager
+namespace URLAccessManager {
+
+/// Return true if access to given url is allowed, false otherwise.
+//
+/// Will use rc file for whitelist/blacklist and localSandbox.
+///
+/// @param url
+///   The url to check
+///
+/// @param baseurl
+///   The originating url, only used for local urls and only
+///   for protocol checking (ie: a non-local originating url
+///   will not be allowed to load a local url)
+///
+bool allow(const URL& url, const URL& baseurl);
+
+//bool allowHost(const std::string& str);
+
+// Used by XMLSocket::connect (and others?)
+bool allowXMLSocket(const std::string& str, short port);
+
+} // AccessManager
+
+} // namespace gnash
+
+#endif // _GNASH_URLACCESSMANAGER_H

http://git.savannah.gnu.org/cgit//commit/?id=ef2819bdf09e1ff27f63100c73fdb25779f2fd62


commit ef2819bdf09e1ff27f63100c73fdb25779f2fd62
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 31 15:47:41 2010 +0100

    Move StreamProvider to libbase.

diff --git a/libbase/Makefile.am b/libbase/Makefile.am
index 5998492..266d6ea 100644
--- a/libbase/Makefile.am
+++ b/libbase/Makefile.am
@@ -87,6 +87,7 @@ libgnashbase_la_SOURCES = \
        GC.cpp \
        BitsReader.cpp \
        arg_parser.cpp \
+       StreamProvider.cpp \
        $(NULL)
 
 
@@ -183,6 +184,7 @@ inst_HEADERS = \
        getclocktime.hpp \
        GnashAlgorithm.h \
        GnashFactory.h \
+       StreamProvider.h \
        $(NULL)
 
 if USE_PNG
diff --git a/libcore/StreamProvider.cpp b/libbase/StreamProvider.cpp
similarity index 100%
rename from libcore/StreamProvider.cpp
rename to libbase/StreamProvider.cpp
diff --git a/libcore/StreamProvider.h b/libbase/StreamProvider.h
similarity index 100%
rename from libcore/StreamProvider.h
rename to libbase/StreamProvider.h
diff --git a/libcore/Makefile.am b/libcore/Makefile.am
index dc88788..9d89b14 100644
--- a/libcore/Makefile.am
+++ b/libcore/Makefile.am
@@ -114,7 +114,6 @@ libgnashcore_la_SOURCES = \
        Function.cpp \
        Function2.cpp \
        Video.cpp \
-       StreamProvider.cpp \
        Button.cpp \
        DisplayList.cpp \
        FillStyle.cpp \
@@ -250,7 +249,6 @@ EXTENSIONS_API = \
        DisplayObjectContainer.h \
        DisplayObject.h \
        MovieClip.h \
-       StreamProvider.h \
        event_id.h \
        SWFMatrix.h \
        SWFCxForm.h \

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

Summary of changes:
 gui/Player.cpp                                     |   14 +++--
 gui/gui.cpp                                        |    3 +-
 gui/pythonmod/gnash-view.cpp                       |    3 +-
 libbase/Makefile.am                                |    4 ++
 {libcore => libbase}/StreamProvider.cpp            |   29 ++++------
 {libcore => libbase}/StreamProvider.h              |   54 +++++++++++++------
 {libcore => libbase}/URLAccessManager.cpp          |    0
 {libcore => libbase}/URLAccessManager.h            |    0
 libcore/Makefile.am                                |    4 --
 libcore/MovieClip.cpp                              |    2 +-
 libcore/MovieFactory.cpp                           |    2 +-
 libcore/MovieLoader.cpp                            |    2 +-
 libcore/RunResources.h                             |   19 ++-----
 libcore/asobj/LoadableObject.cpp                   |    4 +-
 libcore/asobj/LocalConnection_as.cpp               |    2 +-
 libcore/asobj/NetConnection_as.cpp                 |    8 ++--
 libcore/asobj/SharedObject_as.cpp                  |    4 +-
 libcore/asobj/Sound_as.cpp                         |    2 +-
 .../asobj/flash/external/ExternalInterface_as.cpp  |    2 +-
 libcore/movie_root.cpp                             |    2 +-
 libcore/movie_root.h                               |    2 +-
 libcore/swf/ImportAssetsTag.h                      |    2 +-
 testsuite/MovieTester.cpp                          |    2 +-
 testsuite/libcore.all/AsValueTest.cpp              |    4 +-
 testsuite/libcore.all/DisplayListTest.cpp          |    3 +-
 testsuite/libcore.all/PropertyListTest.cpp         |    3 +-
 utilities/processor.cpp                            |    2 +-
 27 files changed, 94 insertions(+), 84 deletions(-)
 rename {libcore => libbase}/StreamProvider.cpp (91%)
 rename {libcore => libbase}/StreamProvider.h (64%)
 rename {libcore => libbase}/URLAccessManager.cpp (100%)
 rename {libcore => libbase}/URLAccessManager.h (100%)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]