Bug 448652 - Very Long URL seems to be blocked by "Security Zone Policy"; "v2.3"; r=sdwilsh
authorJim Mathies <jmathies@mozilla.com>
Sat, 01 Nov 2008 01:22:45 +0100
changeset 21161 cdb84fbfb5bb9d407c47f36b426972eb0c579b22
parent 21160 7e750c55fd897ae7e2f65e5590cd067d4b8c7693
child 21162 5587400a222e81838c6684d1a10f3ed9c21dad6c
push id3367
push usersgautherie.bz@free.fr
push dateSat, 01 Nov 2008 00:23:05 +0000
treeherdermozilla-central@cdb84fbfb5bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh
bugs448652
milestone1.9.1b2pre
Bug 448652 - Very Long URL seems to be blocked by "Security Zone Policy"; "v2.3"; r=sdwilsh
toolkit/components/downloads/src/nsDownloadScanner.cpp
--- a/toolkit/components/downloads/src/nsDownloadScanner.cpp
+++ b/toolkit/components/downloads/src/nsDownloadScanner.cpp
@@ -147,16 +147,19 @@
   0xea } }
 #endif
 static const GUID GUID_MozillaVirusScannerPromptGeneric =
   MOZ_VIRUS_SCANNER_PROMPT_GUID;
 
 // Initial timeout is 30 seconds
 #define WATCHDOG_TIMEOUT (30*PR_USEC_PER_SEC)
 
+// Maximum length for URI's passed into IAE
+#define MAX_IAEURILENGTH 1683
+
 class nsDownloadScannerWatchdog 
 {
   typedef nsDownloadScanner::Scan Scan;
 public:
   nsDownloadScannerWatchdog();
   ~nsDownloadScannerWatchdog();
 
   nsresult Init();
@@ -382,16 +385,19 @@ nsDownloadScanner::CheckPolicy(nsIURI *a
   hr = ae->CheckPolicy();
 
   if (hr == S_OK)
     return AVPOLICY_DOWNLOAD;
 
   if (hr == S_FALSE)
     return AVPOLICY_PROMPT;
 
+  if (hr == E_INVALIDARG)
+    return AVPOLICY_PROMPT;
+
   return AVPOLICY_BLOCKED;
 }
 
 #ifndef THREAD_MODE_BACKGROUND_BEGIN
 #define THREAD_MODE_BACKGROUND_BEGIN 0x00010000
 #endif
 
 #ifndef THREAD_MODE_BACKGROUND_END
@@ -476,16 +482,23 @@ nsDownloadScanner::Scan::Start()
   nsCOMPtr<nsIURI> uri;
   rv = mDownload->GetSource(getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCAutoString origin;
   rv = uri->GetSpec(origin);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  // Certain virus interfaces do not like extremely long uris.
+  // Chop off the path and cgi data and just pass the base domain. 
+  if (origin.Length() > MAX_IAEURILENGTH) {
+    rv = uri->GetPrePath(origin);
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
   CopyUTF8toUTF16(origin, mOrigin);
 
   // We count https/ftp/http as an http download
   PRBool isHttp(PR_FALSE), isFtp(PR_FALSE), isHttps(PR_FALSE);
   nsCOMPtr<nsIURI> innerURI = NS_GetInnermostURI(uri);
   if (!innerURI) innerURI = uri;
   (void)innerURI->SchemeIs("http", &isHttp);
   (void)innerURI->SchemeIs("ftp", &isFtp);
@@ -601,16 +614,20 @@ nsDownloadScanner::Scan::DoScanAES()
       }
       else if (SUCCEEDED(hr)) { // Passed the scan
         newState = AVSCAN_GOOD;
       }
       else if (HRESULT_CODE(hr) == ERROR_FILE_NOT_FOUND) {
         NS_WARNING("Downloaded file disappeared before it could be scanned");
         newState = AVSCAN_FAILED;
       }
+      else if (hr == E_INVALIDARG) {
+        NS_WARNING("IAttachementExecute returned invalid argument error");
+        newState = AVSCAN_FAILED;
+      }
       else { 
         newState = AVSCAN_UGLY;
       }
     }
     else {
       newState = AVSCAN_FAILED;
     }
     return CheckAndSetState(newState, AVSCAN_SCANNING);