Description: Use window.document.baseURI rather than
 window.document.location.href. The former honours <base> tags, fixing bug
 #31497  (aka easy come, easy go)
Author: Sandro Santilli <strk@keybit.net>
Bug: https://savannah.gnu.org/bugs/?31497

--- a/plugin/npapi/plugin.cpp
+++ b/plugin/npapi/plugin.cpp
@@ -1218,6 +1218,13 @@
 std::string
 nsPluginInstance::getCurrentPageURL() const
 {
+    // Return:
+    //  window.document.baseURI
+    //
+    // Was (bogus):
+    //  window.document.location.href
+    //
+
     NPP npp = _instance;
 
     NPIdentifier sDocument = NPN_GetStringIdentifier("document");
@@ -1230,20 +1237,21 @@
     NPN_ReleaseObject(window);
 
     if (!NPVARIANT_IS_OBJECT(vDoc)) {
-        gnash::log_error("Can't get window object");
-        return NULL;
+        gnash::log_error("Can't get window.document object");
+        return std::string();
     }
     
     NPObject* npDoc = NPVARIANT_TO_OBJECT(vDoc);
 
+/*
     NPIdentifier sLocation = NPN_GetStringIdentifier("location");
     NPVariant vLoc;
     NPN_GetProperty(npp, npDoc, sLocation, &vLoc);
     NPN_ReleaseObject(npDoc);
 
     if (!NPVARIANT_IS_OBJECT(vLoc)) {
-        gnash::log_error("Can't get window.location object");
-        return NULL;
+        gnash::log_error("Can't get window.document.location object");
+        return std::string();
     }
 
     NPObject* npLoc = NPVARIANT_TO_OBJECT(vLoc);
@@ -1254,8 +1262,19 @@
     NPN_ReleaseObject(npLoc);
 
     if (!NPVARIANT_IS_STRING(vProp)) {
-        gnash::log_error("Can't get window.location.href object");
-        return NULL;
+        gnash::log_error("Can't get window.document.location.href string");
+        return std::string();
+    }
+*/
+
+    NPIdentifier sProperty = NPN_GetStringIdentifier("baseURI");
+    NPVariant vProp;
+    NPN_GetProperty(npp, npDoc, sProperty, &vProp);
+    NPN_ReleaseObject(npDoc);
+
+    if (!NPVARIANT_IS_STRING(vProp)) {
+        gnash::log_error("Can't get window.document.baseURI string");
+        return std::string();
     }
 
     const NPString& propValue = NPVARIANT_TO_STRING(vProp);
