From 9ed65880ca2f97e525dbb3c1bbe2aed3e2838583 Mon Sep 17 00:00:00 2001 From: "sicking%bigfoot.com" Date: Tue, 4 Mar 2003 12:12:48 +0000 Subject: [PATCH] Bug 184159: Make scripts with for- and event-attributes not lock up the xml-contentsink. r=peterv sr=jst --- content/base/public/nsContentErrors.h | 4 + content/base/src/nsScriptLoader.cpp | 74 +++++++++++ content/base/src/nsScriptLoader.h | 1 + .../html/content/src/nsHTMLScriptElement.cpp | 119 +++++------------- 4 files changed, 108 insertions(+), 90 deletions(-) diff --git a/content/base/public/nsContentErrors.h b/content/base/public/nsContentErrors.h index c46f50cf22cf..dfb1a4034814 100644 --- a/content/base/public/nsContentErrors.h +++ b/content/base/public/nsContentErrors.h @@ -73,4 +73,8 @@ #define NS_XML_AUTOLINK_UNDEFINED \ NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 7) +/** Error codes for nsIScriptLoader */ +#define NS_CONTENT_SCRIPT_IS_EVENTHANDLER \ + NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 8) + #endif // nsContentErrors_h___ diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index 4ee166182fcd..606d46c93f86 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -42,6 +42,8 @@ #include "nsIScriptElement.h" #include "nsIDocShell.h" #include "jsapi.h" +#include "nsContentUtils.h" +#include "nsUnicharUtils.h" static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID); @@ -234,6 +236,72 @@ nsScriptLoader::InNonScriptingContainer(nsIDOMHTMLScriptElement* aScriptElement) return PR_FALSE; } +// Helper method for checking if the script element is an event-handler +// This means that it has both a for-attribute and a event-attribute. +// Also, if the for-attribute has a value that matches "\s*window\s*", +// and the event-attribute matches "\s*onload([ \(].*)?" then it isn't an +// eventhandler. (both matches are case insensitive). +// This is how IE seems to filter out a window's onload handler from a +//