diff --git a/content/base/src/nsHTMLContentSerializer.cpp b/content/base/src/nsHTMLContentSerializer.cpp
index 875feb19753b..3e70d42ed517 100644
--- a/content/base/src/nsHTMLContentSerializer.cpp
+++ b/content/base/src/nsHTMLContentSerializer.cpp
@@ -201,12 +201,13 @@ nsHTMLContentSerializer::IsJavaScript(nsIAtom* aAttrNameAtom, const nsAString& a
{
if (aAttrNameAtom == nsHTMLAtoms::href
|| aAttrNameAtom == nsHTMLAtoms::src) {
- // note that there is a problem in that if this value starts with leading spaces we won't do the right thing
- // this is covered in bug #59604
static const char kJavaScript[] = "javascript";
PRInt32 pos = aValueString.FindChar(':');
- const nsAutoString scheme(Substring(aValueString, 0, pos));
- if ((pos == (PRInt32)(sizeof kJavaScript - 1)) &&
+ if ( pos < (PRInt32)(sizeof kJavaScript - 1) )
+ return PR_FALSE;
+ nsAutoString scheme(Substring(aValueString, 0, pos));
+ scheme.StripWhitespace();
+ if ((scheme.Length() == (sizeof kJavaScript - 1)) &&
scheme.EqualsIgnoreCase(kJavaScript))
return PR_TRUE;
else