gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10137: Make movie_root::loadMovie()


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10137: Make movie_root::loadMovie() and movie_root::getURL into a consistent
Date: Mon, 27 Oct 2008 11:39:37 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10137
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2008-10-27 11:39:37 +0100
message:
  Make movie_root::loadMovie() and movie_root::getURL into a consistent
  interface taking url, target, data and method, so that constructing GET,
  POST or NONE URLs is done in one place. Use a string instead of a URL for
  the same reason. Do not check the validity of the URL, as this is done
  by getStream.
  
  Drop now unnecessary construction of URL and different handling of 
  diffent methods in ASHandlers, LoadableObject, movieclip_loadMovie and
  movieclip_getURL.
  
  Adapt MovieClip::loadVariables similarly.
  
  Send requested URL directly to the hosting application without resolving
  relative URLs ourselves.
  
  Drop unused includes.
modified:
  libcore/MovieClip.cpp
  libcore/MovieClip.h
  libcore/asobj/LoadVars_as.cpp
  libcore/asobj/LoadableObject.cpp
  libcore/movie_root.cpp
  libcore/movie_root.h
  libcore/timers.cpp
  libcore/vm/ASHandlers.cpp
  libcore/vm/ExecutableCode.h
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2008-10-25 15:44:08 +0000
+++ b/libcore/MovieClip.cpp     2008-10-27 10:39:37 +0000
@@ -46,7 +46,6 @@
 #include "URL.h"
 #include "sound_handler.h"
 #include "StreamProvider.h"
-#include "URLAccessManager.h" // for loadVariables
 #include "LoadVariablesThread.h" 
 #include "ExecutableCode.h" // for inheritance of ConstructEvent
 #include "gnash.h" // for get_sound_handler
@@ -806,8 +805,9 @@
     return as_value(movieclip->get_bytes_total());
 }
 
-// my_mc.loadMovie(url:String [,variables:String]).
+// MovieClip.loadMovie(url:String [,variables:String]).
 //
+// Returns 1 for "get", 2 for "post", and otherwise 0. Case-insensitive.
 // This *always* calls MovieClip.meth.
 static as_value
 movieclip_loadMovie(const fn_call& fn)
@@ -844,42 +844,25 @@
         );
         return as_value();
     }
-    const URL& baseurl = get_base_url();
-    URL url(urlstr, baseurl);
 
     movie_root& mr = movieclip->getVM().getRoot();
     std::string target = movieclip->getTarget();
 
     // TODO: if GET/POST should send variables of *this* movie,
     // no matter if the target will be replaced by another movie !!
-    const MovieClip::MovieClipMethod method =
-        static_cast<MovieClip::MovieClipMethod>(val.to_int());
-
-    if (method == MovieClip::METHOD_NONE)
-    {
-        mr.loadMovie(url, target); 
-    }
-    else
-    {
-        std::string data;
+    const MovieClip::VariablesMethod method =
+        static_cast<MovieClip::VariablesMethod>(val.to_int());
+
+    std::string data;
+
+    // This is just an optimization if we aren't going
+    // to send the data anyway. It might be wrong, though.
+    if (method != MovieClip::METHOD_NONE)
+    {
         movieclip->getURLEncodedVars(data);
+    }
  
-        if (method == MovieClip::METHOD_POST)
-        {
-            log_debug(_("POSTING: %s"), data);
-            mr.loadMovie(url, target, &data);
-        }
-        else
-        {
-            // GET method
-            std::string qs = url.querystring();
-            if ( qs.empty() ) data.insert(0, 1, '?');
-            else data.insert(0, 1, '&');
-            url.set_querystring(qs + data);
-            log_debug(_("GETTING: %s"), url.str());
-            mr.loadMovie(url, target); 
-        }
-    }
+    mr.loadMovie(urlstr, target, data, method);
 
     return as_value();
 }
@@ -922,14 +905,12 @@
         );
         return as_value();
     }
-    const URL& baseurl = get_base_url();
-    URL url(urlstr, baseurl);
-
-    const MovieClip::MovieClipMethod method =
-        static_cast<MovieClip::MovieClipMethod>(val.to_int());
-
-    movieclip->loadVariables(url, method);
-    log_debug("MovieClip.loadVariables(%s) - TESTING ", url.str());
+
+    const MovieClip::VariablesMethod method =
+        static_cast<MovieClip::VariablesMethod>(val.to_int());
+
+    movieclip->loadVariables(urlstr, method);
+    log_debug("MovieClip.loadVariables(%s) - TESTING ", urlstr);
 
     return as_value();
 }
@@ -1107,7 +1088,7 @@
     boost::intrusive_ptr<MovieClip> movieclip = 
             ensureType<MovieClip>(fn.this_ptr);
 
-    std::string urlstring;
+    std::string urlstr;
     std::string target;
 
     as_value val;
@@ -1140,13 +1121,13 @@
         case 2:
              target = fn.arg(1).to_string();
         case 1:
-             urlstring = fn.arg(0).to_string();
+             urlstr = fn.arg(0).to_string();
              break;
     }
 
 
-    MovieClip::MovieClipMethod method =
-        static_cast<MovieClip::MovieClipMethod>(val.to_int());
+    MovieClip::VariablesMethod method =
+        static_cast<MovieClip::VariablesMethod>(val.to_int());
 
     std::string vars;
 
@@ -1158,23 +1139,7 @@
 
     movie_root& m = movieclip->getVM().getRoot();
     
-    URL url(urlstring, get_base_url());
-
-    switch (method)
-    {
-        case MovieClip::METHOD_POST:
-            m.getURL(url, target, &vars);
-            break;
-        case MovieClip::METHOD_GET:
-        {
-            std::string qs = url.querystring();
-            if ( qs.empty() ) vars.insert(0, 1, '?');
-            else vars.insert(0, 1, '&');
-            url.set_querystring(qs + vars);
-        }
-        case MovieClip::METHOD_NONE:
-            m.getURL(url, target);
-    }
+    m.getURL(urlstr, target, vars, method);
 
     return as_value();
 }
@@ -3400,7 +3365,7 @@
 
     // I'm not sure ENTERFRAME goes in a different queue then DOACTION...
     queueEvent(event_id::ENTER_FRAME, movie_root::apDOACTION);
-    //queueEvent(event_id::ENTER_FRAME, movie_root::apENTERFRAME);
+    //queueEvent(event_id::ENTER_FRAME, apENTERFRAME);
 
     // Update current and next frames.
     if (m_play_state == PLAY)
@@ -4852,7 +4817,7 @@
 {
     // Get a pointer to our own parent 
     character* parent = get_parent();
-    if ( parent )
+    if (parent)
     {
         if (postdata)
         {
@@ -4927,18 +4892,18 @@
 }
 
 void 
-MovieClip::loadVariables(URL url, MovieClipMethod sendVarsMethod)
+MovieClip::loadVariables(const std::string& urlstr, 
+        VariablesMethod sendVarsMethod)
 {
-    // Check host security
-    // will be done by LoadVariablesThread (down by getStream, that is)
-    //if ( ! URLAccessManager::allow(url) ) return;
+    // Host security check will be will be done by LoadVariablesThread
+    // (down by getStream, that is)
     
+    URL url(urlstr, get_base_url());
+
     std::string postdata;
     
-    if ( sendVarsMethod != METHOD_NONE)
-    {
-        getURLEncodedVars(postdata);
-    }
+    // Encode our vars for sending.
+    if (sendVarsMethod != METHOD_NONE) getURLEncodedVars(postdata);
 
     try 
     {

=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h       2008-10-27 08:10:25 +0000
+++ b/libcore/MovieClip.h       2008-10-27 10:39:37 +0000
@@ -18,8 +18,8 @@
 
 // Stateful live Sprite instance
 
-#ifndef GNASH_SPRITE_INSTANCE_H
-#define GNASH_SPRITE_INSTANCE_H
+#ifndef GNASH_MOVIECLIP_H
+#define GNASH_MOVIECLIP_H
 
 #ifdef HAVE_CONFIG_H
 #include "gnashconfig.h" // GNASH_USE_GC, USE_SWFTREE
@@ -30,7 +30,6 @@
 #include "log.h"
 #include "as_environment.h" // for composition
 #include "DynamicShape.h" // for composition
-//#include "LoadVariablesThread.h" // for composition
 #include "Range2d.h"
 #include "dsodefs.h" // for DSOEXPORT
 
@@ -51,7 +50,7 @@
     class LoadVariablesThread;
     class gradient_record;
     class edit_text_character;
-    namespace SWF{
+    namespace SWF {
         class PlaceObject2Tag;
     }
 }
@@ -126,13 +125,6 @@
         TAG_DLIST  = 1<<1
     };
 
-    enum MovieClipMethod
-    {
-        METHOD_NONE = 0,
-        METHOD_GET,
-        METHOD_POST
-    };
-
     // Overridden to use the m_root member
     virtual movie_instance* get_root() const;
 
@@ -515,6 +507,16 @@
 
     MovieClip* to_movie () { return this; }
 
+    /// The various methods for sending data in requests.
+    //
+    /// Used in loadMovie, getURL, loadVariables etc.
+    enum VariablesMethod
+    {
+        METHOD_NONE = 0,
+        METHOD_GET,
+        METHOD_POST
+    };
+
     /// Load a movie in this sprite, replacing it
     //
     /// @param url
@@ -531,24 +533,20 @@
     /// Load url-encoded variables from the given url, optionally
     /// sending variables from this timeline too.
     //
-    ///
     /// A LoadVariablesThread will be started to load and parse variables
     /// and added to the _loadVariableRequests. Then, at every ::advance_sprite
     /// any completed threads will be processed
     /// (see processCompletedLoadVariableRequests)
     ///
-    /// NOTE: the given url will be securit-checked
-    ///
-    /// @param url
-    /// The url to load variables from. It is expected that
-    /// the caller already checked host security.
-    ///
-    /// @param sendVarsMethod
-    /// If 0 (the default) no variables will be sent.
-    /// If 1, GET will be used.
-    /// If 2, POST will be used.
-    ///
-    void loadVariables(URL url, MovieClipMethod sendVarsMethod);
+    /// NOTE: the given url will be security-checked
+    ///
+    /// @param urlstr: The url to load variables from.
+    ///
+    /// @param sendVarsMethod: The VariablesMethod to use. If METHOD_NONE,
+    ///                        no data will be sent.
+    ///
+    void loadVariables(const std::string& urlstr,
+            VariablesMethod sendVarsMethod);
 
     //
     // ActionScript support

=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp     2008-10-25 18:51:18 +0000
+++ b/libcore/asobj/LoadVars_as.cpp     2008-10-27 10:39:37 +0000
@@ -286,7 +286,8 @@
 
        if ( cl == NULL )
        {
-               cl=new builtin_function(&loadvars_ctor, 
LoadVars_as::getLoadVarsInterface());
+               cl=new builtin_function(&loadvars_ctor,
+                LoadVars_as::getLoadVarsInterface());
                // replicate all interface to class, to be able to access
                // all methods as static functions
                LoadVars_as::attachLoadVarsInterface(*cl);

=== modified file 'libcore/asobj/LoadableObject.cpp'
--- a/libcore/asobj/LoadableObject.cpp  2008-10-23 18:27:11 +0000
+++ b/libcore/asobj/LoadableObject.cpp  2008-10-27 10:39:37 +0000
@@ -67,7 +67,6 @@
         bool post)
 {
     movie_root& m = _vm.getRoot();
-    URL url(urlstr);
 
     // Encode the object for HTTP. If post is true,
     // XML should not be encoded. LoadVars is always
@@ -76,19 +75,11 @@
     std::ostringstream data;
     toString(data, !post);
 
-    const std::string& datastring = data.str();
-
-    if (post)
-    {
-        m.getURL(url, target, &datastring);
-        return;
-    }
-
-    // GET
-    std::string qs = url.querystring();
-    if (qs.empty()) url.set_querystring(datastring);
-    else url.set_querystring(qs + "&" + datastring);
-    m.getURL(url, target);
+    // Only GET and POST are possible here.
+    MovieClip::VariablesMethod method = post ? MovieClip::METHOD_POST :
+                                               MovieClip::METHOD_GET;
+
+    m.getURL(urlstr, target, data.str(), method);
 
 }
 

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2008-10-25 10:38:32 +0000
+++ b/libcore/movie_root.cpp    2008-10-27 10:39:37 +0000
@@ -2049,12 +2049,17 @@
 }
 
 void
-movie_root::getURL(const URL& url, const std::string& target,
-        const std::string* postdata)
+movie_root::getURL(const std::string& urlstr, const std::string& target,
+        const std::string& data, MovieClip::VariablesMethod method)
 {
 
     if (_hostfd == -1)
     {
+        /// 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, get_base_url());
+
         gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
         std::string command = rcfile.getURLOpenerFormat();
 
@@ -2096,52 +2101,88 @@
 
         log_debug (_("Launching URL: %s"), command);
         std::system(command.c_str());
-    }
-    else
-    {
-        std::ostringstream request;
-        if (postdata)
-        {
-            request << "POST " << target << ":" << 
-                *postdata << "$" << url << std::endl;
-        }
-        else
-        {
-            // use the original url, non parsed (the browser will know better
-            // how to resolve relative urls and handle actionscript)
-            request << "GET " << target << ":" << url << std::endl;
-        }
-
-        std::string requestString = request.str();
-        size_t len = requestString.length();
-        // TODO: should mutex-protect this ?
-        // NOTE: we are assuming the hostfd is set in blocking mode here..
-        log_debug(_("Attempt to write geturl requests fd %d"), _hostfd);
-
-        int ret = write(_hostfd, requestString.c_str(), len);
-        if (ret == -1)
-        {
-            log_error(_("Could not write to user-provided host requests "
-                        "fd %d: %s"), _hostfd, std::strerror(errno));
-        }
-        if (static_cast<size_t>(ret) < len)
-        {
-            log_error(_("Could only write %d bytes over %d required to "
-                        "user-provided host requests fd %d"),
-                        ret, len, _hostfd);
-        }
-
-        // The request string ends with newline, and we don't want to log that
-        requestString.resize(requestString.size() - 1);
-        log_debug(_("Sent request '%s' to host fd %d"), requestString, 
_hostfd);
-    }
+        return;
+    }
+
+    /// This is when there is a hosting application.
+    std::ostringstream request;
+    std::string querystring;
+    switch (method)
+    {
+        case MovieClip::METHOD_POST:
+             request << "POST " << target << ":" << 
+                data << "$" << urlstr << std::endl;
+             break;
+
+        // METHOD_GET and METHOD_NONE are the same, except that
+        // for METHOD_GET we append the variables to the query
+        // string.
+        case MovieClip::METHOD_GET:
+            // Append vars to URL query string
+            if (urlstr.find("?") == std::string::npos) {
+                querystring = "?";
+            }
+            else querystring = "&";
+            querystring.append(data);
+
+        case MovieClip::METHOD_NONE:
+            // use the original url, non parsed (the browser will know
+            // better how to resolve relative urls and handle
+            // javascript)
+            request << "GET " << target << ":" << urlstr << std::endl;
+            break;
+    }
+
+    std::string requestString = request.str();
+    size_t len = requestString.length();
+    // TODO: should mutex-protect this ?
+    // NOTE: we are assuming the hostfd is set in blocking mode here..
+    log_debug(_("Attempt to write geturl requests fd %d"), _hostfd);
+
+    int ret = write(_hostfd, requestString.c_str(), len);
+    if (ret == -1)
+    {
+        log_error(_("Could not write to user-provided host requests "
+                    "fd %d: %s"), _hostfd, std::strerror(errno));
+    }
+    if (static_cast<size_t>(ret) < len)
+    {
+        log_error(_("Could only write %d bytes over %d required to "
+                    "user-provided host requests fd %d"),
+                    ret, len, _hostfd);
+    }
+
+    // The request string ends with newline, and we don't want to log that
+    requestString.resize(requestString.size() - 1);
+    log_debug(_("Sent request '%s' to host fd %d"), requestString, _hostfd);
 
 }
 
 void
-movie_root::loadMovie(const URL& url, const std::string& target, const 
std::string* postdata)
+movie_root::loadMovie(const std::string& urlstr, const std::string& target,
+        const std::string& data, MovieClip::VariablesMethod method)
 {
+
+    /// Where is the security checked?
+    URL url(urlstr, get_base_url());
+
+    /// If the method is MovieClip::METHOD_NONE, we send no data.
+    if (method == MovieClip::METHOD_GET)
+    {
+        std::string varsToSend(urlstr);
+        /// GET: append data to query string.
+        std::string qs = url.querystring();
+        if ( qs.empty() ) varsToSend.insert(0, 1, '?');
+        else varsToSend.insert(0, 1, '&');
+        url.set_querystring(qs + varsToSend);
+    }
+
     log_debug("movie_root::loadMovie(%s, %s)", url.str(), target);
+
+    const std::string* postdata = NULL;
+
+    /// POST: send variables using the POST method.
+    if (method == MovieClip::METHOD_POST) postdata = &data;
     _loadMovieRequests.push_front(LoadMovieRequest(url, target, postdata));
 }
 

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2008-10-25 10:38:32 +0000
+++ b/libcore/movie_root.h      2008-10-27 10:39:37 +0000
@@ -73,11 +73,11 @@
 #include "dsodefs.h" // DSOEXPORT
 #include "mouse_button_state.h" // for composition
 #include "drag_state.h" // for composition
-#include "movie_instance.h" // for inlines
 #include "asobj/Key_as.h"
 #include "smart_ptr.h" // for memory management
 #include "URL.h" // for loadMovie
 #include "GnashKey.h" // key::code
+#include "movie_instance.h"
 
 #ifdef USE_SWFTREE
 # include "tree.hh"
@@ -104,6 +104,7 @@
     class Stage_as;
     class URL;
     class Timer;
+    class MovieClip;
 }
 
 namespace gnash
@@ -308,7 +309,7 @@
     /// @return the originating root movie (not necessarely _level0)
     movie_instance* getRootMovie() const
     {
-       return _rootMovie.get();
+           return _rootMovie.get();
     }
 
     void stop_drag()
@@ -352,7 +353,7 @@
     ///
     size_t get_current_frame() const
     {
-       return getRootMovie()->get_current_frame();
+           return getRootMovie()->get_current_frame();
     }
 
     void set_background_color(const rgba& color);
@@ -398,7 +399,7 @@
     ///
     void set_play_state(MovieClip::play_state s)
     {
-       getRootMovie()->set_play_state(s);
+           getRootMovie()->set_play_state(s);
     }
 
        /// Notify still loaded character listeners for key events
@@ -651,36 +652,35 @@
 
     /// Queue a request for loading a movie
     //
-    /// @param url
-    ///                The url to load.
-    ///
-    /// @param target
-    ///            Target to load into.
-    ///
-    /// @param postdata
-    ///     If not null, the data to POST in an HTTP request.
-    ///     Tests show that if you queue a load request for a target which
-    ///     is unloaded at time of processing, you still get the original
-    ///     target variables posted, not the new ones !
-    ///            See http://savannah.gnu.org/bugs/index.php?22257
-    ///
-    void loadMovie(const URL& url, const std::string& target,
-            const std::string* postdata = NULL);
-
+    /// This function constructs the URL and, if required, the postdata
+    /// from the arguments. The variables to send should *not* be appended
+    /// to @param urlstr before calling this function.
+    //
+    /// @param urlstr   The url exactly as requested. This may already
+    ///                 contain a query string.
+    /// @param target   Target for request.
+    /// @param data     The variables data to send, URL encoded in
+    ///                 key/value pairs
+    /// @param method   The VariablesMethod to use for sending the data. If
+    ///                 MovieClip::METHOD_NONE, no data will be sent.
+    void loadMovie(const std::string& url, const std::string& target,
+            const std::string& data, MovieClip::VariablesMethod method);
 
     /// Send a request to the hosting application (e.g. browser).
     //
-    /// @param url
-    ///                The url to request.
-    ///
-    /// @param target
-    ///            Target for request.
-    ///
-    /// @param postdata
-    ///     If not null, the data to POST in an HTTP request.
-    ///
-    void getURL(const URL& url, const std::string& target,
-            const std::string* postdata = NULL);
+    /// This function constructs the URL and, if required, the postdata
+    /// from the arguments. The variables to send should *not* be appended
+    /// to @param urlstr before calling this function.
+    //
+    /// @param urlstr   The url exactly as requested. This may already
+    ///                 contain a query string.
+    /// @param target   Target for request.
+    /// @param data     The variables data to send, URL encoded in
+    ///                 key/value pairs
+    /// @param method   The VariablesMethod to use for sending the data. If
+    ///                 MovieClip::METHOD_NONE, no data will be sent.
+    void getURL(const std::string& urlstr, const std::string& target,
+            const std::string& data, MovieClip::VariablesMethod method);
 
 
     /// Return true if the given string can be interpreted as a _level name

=== modified file 'libcore/timers.cpp'
--- a/libcore/timers.cpp        2008-10-25 10:38:32 +0000
+++ b/libcore/timers.cpp        2008-10-27 10:39:37 +0000
@@ -24,7 +24,6 @@
 #include "as_function.h" // for class as_function
 #include "as_object.h" // for inheritance
 #include "log.h"
-#include "MovieClip.h"
 #include "fn_call.h"
 #include "VM.h"
 #include "movie_root.h"

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2008-10-25 16:13:26 +0000
+++ b/libcore/vm/ASHandlers.cpp 2008-10-27 10:39:37 +0000
@@ -36,7 +36,6 @@
 #include "MovieClip.h"
 #include "as_environment.h"
 #include "URL.h"
-#include "URLAccessManager.h" // for GetUrl actions
 #include "action_buffer.h"
 #include "as_object.h"
 #include "Object.h"
@@ -2146,10 +2145,10 @@
 void
 SWFHandlers::CommonGetUrl(as_environment& env,
         as_value target, // the target window, or _level1..10
-        const std::string& urlTarget, boost::uint8_t method)
+        const std::string& url, boost::uint8_t method)
 {
 
-    if (urlTarget.empty())
+    if (url.empty())
     {
         log_error(_("Bogus empty GetUrl url in SWF file, skipping"));
         return;
@@ -2159,17 +2158,17 @@
     bool loadTargetFlag    = method & 64;
     bool loadVariableFlag  = method & 128;
 
-    MovieClip::MovieClipMethod sendVarsMethod;
+    MovieClip::VariablesMethod sendVarsMethod;
 
     // handle malformed sendVarsMethod
     if ((method & 3) == 3)
     {
         log_error(_("Bogus GetUrl2 send vars method "
-            " in SWF file (both GET and POST requested), use GET"));
+            " in SWF file (both GET and POST requested). Using GET"));
         sendVarsMethod = MovieClip::METHOD_GET;
     }
     else sendVarsMethod =
-        static_cast<MovieClip::MovieClipMethod>(method & 3);
+        static_cast<MovieClip::VariablesMethod>(method & 3);
 
     std::string target_string;
     if ( ! target.is_undefined() && ! target.is_null() )
@@ -2183,15 +2182,15 @@
     // If the url starts with "FSCommand:", then this is
     // a message for the host app.
     StringNoCaseEqual noCaseCompare;
-    if (noCaseCompare(urlTarget.substr(0, 10), "FSCommand:"))
+    if (noCaseCompare(url.substr(0, 10), "FSCommand:"))
     {
-        m.handleFsCommand(urlTarget.substr(10), target_string);
+        m.handleFsCommand(url.substr(10), target_string);
         return;
     }
 
     // If the url starts with "print:", then this is
     // a print request.
-    if (noCaseCompare(urlTarget.substr(0, 6), "print:"))
+    if (noCaseCompare(url.substr(0, 6), "print:"))
     {
         log_unimpl("print: URL");
         return;
@@ -2213,21 +2212,37 @@
     // The base url must be set with the set_base_url() command.
     //
 
-    const URL& baseurl = get_base_url();
-    URL url(urlTarget, baseurl);
-
-    log_debug(_("get url: target=%s, url=%s (%s), method=%x "
+    log_debug(_("get url: target=%s, url=%s, method=%x "
                 "(sendVars:%X, loadTarget:%d, loadVariable:%d)"),
-            target_string, url.str(), urlTarget, static_cast<int>(method),
+            target_string, url, static_cast<int>(method),
             sendVarsMethod, loadTargetFlag, loadVariableFlag);
 
-    if ( ! URLAccessManager::allow(url) )
+    character* target_ch = env.find_target(target.to_string());
+    MovieClip* target_movie = target_ch ? target_ch->to_movie() : 0;
+
+    if (loadVariableFlag)
     {
+        log_debug(_("getURL2 loadVariable"));
+
+        if (!target_ch)
+        {
+            log_error(_("getURL: target %s not found"), target_string);
+            // might want to invoke the external url opener here...
+            return;
+        }
+
+        if (!target_movie)
+        {
+            log_error(_("getURL: target %s is not a sprite"), target_string);
+            // might want to invoke the external url opener here...
+            return;
+        }
+
+        target_movie->loadVariables(url, sendVarsMethod);
+
         return;
     }
 
-    bool post = (sendVarsMethod == MovieClip::METHOD_POST);
-
     std::string varsToSend;
     if (sendVarsMethod != MovieClip::METHOD_NONE)
     {
@@ -2243,62 +2258,21 @@
             return;
         }
         curtgt->getURLEncodedVars(varsToSend);
-        if (!post)
-        {
-            // we're using GET
-            std::string qs = url.querystring();
-            if ( qs.empty() ) varsToSend.insert(0, 1, '?');
-            else varsToSend.insert(0, 1, '&');
-            url.set_querystring(qs+varsToSend);
-        }
-    }
-
-    character* target_ch = env.find_target(target.to_string());
-    MovieClip* target_movie = target_ch ? target_ch->to_movie() : 0;
-
-    if (loadVariableFlag)
-    {
-        log_debug(_("getURL2 loadVariable"));
-
-        if ( ! target_ch )
-        {
-            log_error(_("getURL: target %s not found"),
-                target_string);
-            // might want to invoke the external url opener here...
-            return;
-        }
-
-        if ( ! target_movie )
-        {
-            log_error(_("getURL: target %s is not a sprite"),
-                target_string);
-            // might want to invoke the external url opener here...
-            return;
-        }
-
-        if (post)
-        {
-            log_unimpl(_("POST with loadVariables ignored"));
-        }
-        target_movie->loadVariables(url,
-                static_cast<MovieClip::MovieClipMethod>(sendVarsMethod));
-
-        return;
-    }
+    }
+
 
     if ( loadTargetFlag )
     {
         log_debug(_("getURL2 target load"));
 
-        if ( ! target_ch )
+        if (!target_ch)
         {
             unsigned int levelno;
-            if ( m.isLevelTarget(target_string, levelno) )
+            if (m.isLevelTarget(target_string, levelno))
             {
                 log_debug(_("Testing _level loading (level %u)"), levelno);
  
-                if (post) m.loadMovie(url, target_string, &varsToSend);
-                else m.loadMovie(url, target_string); // using GET
+                m.loadMovie(url, target_string, varsToSend, sendVarsMethod);
                 return;
             }
 
@@ -2318,38 +2292,37 @@
 
         if (!target_movie)
         {
-            log_error(_("get url: target %s is not a sprite"),
-                target_string);
+            log_error(_("get url: target %s is not a sprite"), target_string);
             return;
         }
 
         std::string s = target_movie->getTarget(); // or getOrigTarget ?
-        if ( s != target_movie->getOrigTarget() )
+        if (s != target_movie->getOrigTarget())
         {
             log_debug(_("TESTME: target of a loadMovie changed its target "
                         "path"));
         }
+        
         // TODO: try to trigger this !
         assert(m.findCharacterByTarget(s) == target_movie );
 
-        if (post) m.loadMovie(url, s, &varsToSend); 
-        else m.loadMovie(url, s);
+        m.loadMovie(url, s, varsToSend, sendVarsMethod); 
         return;
     }
 
     unsigned int levelno;
-    if ( m.isLevelTarget(target_string, levelno) )
+    if (m.isLevelTarget(target_string, levelno))
     {
         log_debug(_("Testing _level loading (level %u)"), levelno);
-
-        if (post) m.loadMovie(url, target_string, &varsToSend);
-        else m.loadMovie(url, target_string); 
+        m.loadMovie(url, target_string, varsToSend, sendVarsMethod);
         return;
     }
 
     // Just plain getURL
-    if (post) m.getURL(url, target_string, &varsToSend);
-    else m.getURL(url, target_string);
+    // This should be the original URL string, as the hosting application
+    // will decide how to resolve the URL. If there is no hosting
+    // application, movie_root::getURL will resolve the URL.
+    m.getURL(url, target_string, varsToSend, sendVarsMethod);
 
 }
 

=== modified file 'libcore/vm/ExecutableCode.h'
--- a/libcore/vm/ExecutableCode.h       2008-10-25 10:38:32 +0000
+++ b/libcore/vm/ExecutableCode.h       2008-10-27 10:39:37 +0000
@@ -25,7 +25,6 @@
 
 #include "smart_ptr.h" // GNASH_USE_GC
 #include "as_function.h"
-#include "MovieClip.h"
 #include "ActionExec.h"
 #include "fn_call.h"
 


reply via email to

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