From 836df7f932f192d536fb56df77978f80c6c37530 Mon Sep 17 00:00:00 2001 From: Nutchanon Wetchasit Date: Tue, 7 Mar 2017 12:13:37 +0100 Subject: [PATCH] Treat undefined target parameter of MovieClip.getURL() like empty string. See bug #50393 --- libcore/asobj/MovieClip_as.cpp | 12 ++++++++---- testsuite/misc-ming.all/hostcmd_htmltest.sh | 2 +- testsuite/misc-ming.all/hostcmd_testrunner.sh | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libcore/asobj/MovieClip_as.cpp b/libcore/asobj/MovieClip_as.cpp index 8973066b3..ab7fc058a 100644 --- a/libcore/asobj/MovieClip_as.cpp +++ b/libcore/asobj/MovieClip_as.cpp @@ -1092,7 +1092,7 @@ movieclip_getURL(const fn_call& fn) as_object* movieclip = ensure(fn); std::string urlstr; - std::string target; + as_value target; as_value val; if (fn.nargs > 2) @@ -1123,19 +1123,23 @@ movieclip_getURL(const fn_call& fn) case 3: // This argument has already been handled. case 2: - target = fn.arg(1).to_string(); + target = fn.arg(1); case 1: urlstr = fn.arg(0).to_string(); break; } movie_root& m = getRoot(fn); + std::string targetstr; + if (!target.is_undefined()) { + targetstr = target.to_string(); + } // If the URL uses "FSCommand:" scheme, it is a message for the player // or host container. StringNoCaseEqual noCaseCompare; if (noCaseCompare(urlstr.substr(0, 10), "FSCommand:")) { - m.handleFsCommand(urlstr.substr(10), target); + m.handleFsCommand(urlstr.substr(10), targetstr); return as_value(); } @@ -1149,7 +1153,7 @@ movieclip_getURL(const fn_call& fn) vars = getURLEncodedVars(*movieclip); } - m.getURL(urlstr, target, vars, method); + m.getURL(urlstr, targetstr, vars, method); return as_value(); } diff --git a/testsuite/misc-ming.all/hostcmd_htmltest.sh b/testsuite/misc-ming.all/hostcmd_htmltest.sh index 774e5b671..0fffffd5a 100644 --- a/testsuite/misc-ming.all/hostcmd_htmltest.sh +++ b/testsuite/misc-ming.all/hostcmd_htmltest.sh @@ -325,7 +325,7 @@ cat << EOF } else if("m_undefinedarg" == cmd) { m_undefinedarg_call++; check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with undefined parameter should pass string-type parameter"); - xcheck_equals(arg, "", "MovieClip-based FSCommand call should pass an empty string as a representation of undefined parameter"); + check_equals(arg, "", "MovieClip-based FSCommand call should pass an empty string as a representation of undefined parameter"); } else if("m_arrayarg" == cmd) { m_arrayarg_call++; check_equals(typeof(arg), "string", "MovieClip-based FSCommand call with array parameter should pass string-type parameter"); diff --git a/testsuite/misc-ming.all/hostcmd_testrunner.sh b/testsuite/misc-ming.all/hostcmd_testrunner.sh index 509d5a65a..6317e047b 100644 --- a/testsuite/misc-ming.all/hostcmd_testrunner.sh +++ b/testsuite/misc-ming.all/hostcmd_testrunner.sh @@ -307,7 +307,7 @@ check_equals "\$LINE" 'm_undefinedarg' "Gnash should pass undefined parameter of MovieClip-based FSCommand call as empty string" +check_equals "\$LINE" 'm_undefinedarg' "Gnash should pass undefined parameter of MovieClip-based FSCommand call as empty string" # Read for array-parameter FSCommand statement read_timeout LINE \$READTIMEOUT <&3 -- 2.11.4.GIT