From aba67da38b8b983f043b536b9743f80abfb6e33a Mon Sep 17 00:00:00 2001
From: Rick Pasetto <rick@lindenlab.com>
Date: Mon, 5 Oct 2009 18:14:27 -0700
Subject: [PATCH] FIX DEV-40877: ignore changes from "bad" objects which have
 an invalid media URL

---
 indra/llprimitive/lltextureentry.cpp      |  6 ++++++
 indra/llprimitive/lltextureentry.h        |  4 +++-
 indra/newview/app_settings/logcontrol.xml |  4 ++++
 indra/newview/llmediadataclient.cpp       |  2 +-
 indra/newview/llvovolume.cpp              | 24 ++++++++++++++++-------
 5 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp
index b534939dfc4..8f7cd688346 100644
--- a/indra/llprimitive/lltextureentry.cpp
+++ b/indra/llprimitive/lltextureentry.cpp
@@ -646,3 +646,9 @@ LLUUID LLTextureEntry::getAgentIDFromMediaVersionString(const std::string &versi
     }
     return id;
 }
+
+//static
+bool LLTextureEntry::isMediaVersionString(const std::string &version_string)
+{
+	return std::string::npos != version_string.find(MEDIA_VERSION_STRING_PREFIX);
+}
diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h
index 8d2834f78c5..d6366b9bb25 100644
--- a/indra/llprimitive/lltextureentry.h
+++ b/indra/llprimitive/lltextureentry.h
@@ -171,7 +171,9 @@ class LLTextureEntry
     static U32 getVersionFromMediaVersionString(const std::string &version_string);
     // Given a media version string, return the UUID of the agent
     static LLUUID getAgentIDFromMediaVersionString(const std::string &version_string);
-
+	// Return whether or not the given string is actually a media version
+	static bool isMediaVersionString(const std::string &version_string);
+	
 	// Media flags
 	enum { MF_NONE = 0x0, MF_HAS_MEDIA = 0x1 };
 
diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index d7bb64ce8a7..85cb3cf1b47 100644
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -25,6 +25,7 @@
 							<string>AppCache</string>
 							<string>Window</string>
 							<string>RenderInit</string>
+							<string>MediaOnAPrim</string>
 						</array>
 				</map>
 				<map>
@@ -34,12 +35,15 @@
 						</array>
 					<key>classes</key>
 						<array>
+						<string>LLMediaDataClient</string>
 						</array>
 					<key>files</key>
 						<array>
 						</array>
 					<key>tags</key>
 						<array>
+						<string>LLMediaDataClient</string>
+						<string>MediaOnAPrim</string>
 						</array>
 				</map>
 			</array>
diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index 54521ccb847..c356f553151 100644
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -618,6 +618,6 @@ void LLObjectMediaNavigateClient::Responder::bounceBack()
     
     if (mep && impl)
     {
-//        impl->navigateTo(mep->getCurrentURL());
+        impl->navigateTo(mep->getCurrentURL(), "", false, true);
     }
 }
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 583246c23e8..428de078dea 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -319,13 +319,23 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
 			}
 		}
 	}
-	if (retval & (MEDIA_URL_REMOVED | MEDIA_URL_ADDED | MEDIA_URL_UPDATED | MEDIA_FLAGS_CHANGED)) {
-		// If the media changed at all, request new media data
-		if(mMedia)
-		{
-			llinfos << "Media URL: " << mMedia->mMediaURL << llendl;
-		}
-		requestMediaDataUpdate();
+	if (retval & (MEDIA_URL_REMOVED | MEDIA_URL_ADDED | MEDIA_URL_UPDATED | MEDIA_FLAGS_CHANGED)) 
+	{
+		// If only the media URL changed, and it isn't a media version URL,
+		// ignore it
+		if ( ! ( retval & (MEDIA_URL_ADDED | MEDIA_URL_UPDATED) &&
+				 mMedia && ! mMedia->mMediaURL.empty() &&
+				 ! LLTextureEntry::isMediaVersionString(mMedia->mMediaURL) ) )
+		{
+			// If the media changed at all, request new media data
+			LL_DEBUGS("MediaOnAPrim") << "Media update: " << getID() << ": retval=" << retval << " Media URL: " <<
+                ((mMedia) ?  mMedia->mMediaURL : std::string("")) << LL_ENDL;
+			requestMediaDataUpdate();
+		}
+        else {
+            LL_INFOS("MediaOnAPrim") << "Ignoring media update for: " << getID() << " Media URL: " <<
+                ((mMedia) ?  mMedia->mMediaURL : std::string("")) << LL_ENDL;
+        }
 	}
 	// ...and clean up any media impls
 	cleanUpMediaImpls();
-- 
GitLab