Waiting for Olly response
authorRiccardo Pelizzi <r.pelizzi@gmail.com>
Mon, 28 May 2012 23:51:02 -0400
changeset 43 dafd5c7104313ad67d058a813e884b2151cb3c91
parent 42 0b9377ea878bf6998a912cd94c5a6c351cf57aac
child 44 898cf5af7c474a31ec90be6fa415de9a488b24be
child 45 c0fed27360961eadb57b6a1a36ffff6988a1e603
push id25
push userr.pelizzi@gmail.com
push dateTue, 29 May 2012 03:51:10 +0000
Waiting for Olly response
xssfilter
--- a/xssfilter
+++ b/xssfilter
@@ -1187,21 +1187,21 @@ new file mode 100644
 +#ifdef PR_LOGGING
 +static PRLogModuleInfo *gXssPRLog;
 +#endif
 +
 +
 +
 +nsXSSFilter::nsXSSFilter(nsIDocument *parent)
 +  : mParams(),
-+    mParamsInitialized(PR_FALSE),
++    mParamsInitialized(false),
 +    mParentDoc(parent),
 +    mDomainCache(),
-+    mIsEnabled(PR_TRUE),
-+    mBlockMode(PR_FALSE)
++    mIsEnabled(true),
++    mBlockMode(false)
 +{ }
 +
 +nsXSSFilter::~nsXSSFilter()
 +{ }
 +
 +
 +void
 +nsXSSFilter::InitializeStatics()
@@ -1218,19 +1218,19 @@ new file mode 100644
 +}
 +
 +
 +/**
 + * Two Utility function to parse the X-XSS-Protection header.
 + * note: the code for parsing the header purposedly copies Webkit, I
 + * hope that's fine. Returns true if there is more to parse.
 + */
-+PRBool
++bool
 +skipWhiteSpace(const nsACString& str, PRUint32& pos,
-+               PRBool fromHttpEquivMeta)
++               bool fromHttpEquivMeta)
 +{
 +  PRUint32 len = str.Length();
 +
 +  if (fromHttpEquivMeta) {
 +    while (pos != len && str[pos] <= ' ')
 +      ++pos;
 +  } else {
 +    while (pos != len && (str[pos] == '\t' || str[pos] == ' '))
@@ -1238,17 +1238,17 @@ new file mode 100644
 +  }
 +  return pos != len;
 +}
 +
 +/**
 + * Returns true if the function can match the whole token (case insensitive).
 + * Note: Might return pos == str.Length()
 + */
-+PRBool
++bool
 +skipToken(const nsACString& str, PRUint32& pos,
 +          const nsACString& token)
 +{
 +  PRUint32 len = str.Length();
 +  PRUint32 tokenPos = 0;
 +	PRUint32 tokenLen = token.Length();
 +
 +  while (pos != len && tokenPos < tokenLen) {
@@ -1284,268 +1284,268 @@ new file mode 100644
 +  httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-Xss-Protection"),
 +                                 xssHeaderValue);
 +  LOG_XSS_1("Header: '%s'", xssHeaderValue.get());
 +
 +  // no need to skip spaces before the beginning of the string, firefox
 +  // does this for us
 +
 +  if (xssHeaderValue.IsEmpty()) {
-+    mIsEnabled = PR_TRUE;
++    mIsEnabled = true;
 +    return NS_OK;
 +  }
 +  if (xssHeaderValue[0] == '0') {
-+    mIsEnabled = PR_FALSE;
++    mIsEnabled = false;
 +    return NS_OK;
 +  }
 +
 +  PRUint32 len = xssHeaderValue.Length();
 +  PRUint32 pos = 0;
 +
 +  if (xssHeaderValue[pos++] == '1' &&
 +      skipWhiteSpace(xssHeaderValue, pos, false) &&
 +      xssHeaderValue[pos++] == ';' &&
 +      skipWhiteSpace(xssHeaderValue, pos, false) &&
 +      skipToken(xssHeaderValue, pos, NS_LITERAL_CSTRING("mode")) &&
 +      skipWhiteSpace(xssHeaderValue, pos, false) &&
 +      xssHeaderValue[pos++] == '=' &&
 +      skipWhiteSpace(xssHeaderValue, pos, false) &&
 +      skipToken(xssHeaderValue, pos, NS_LITERAL_CSTRING("block")) &&
 +      pos == len) {
-+    mIsEnabled = PR_TRUE;
-+    mBlockMode = PR_TRUE;
++    mIsEnabled = true;
++    mBlockMode = true;
 +    LOG_XSS("Block mode activated");
 +    return NS_OK;
 +  }
 +
 +  // else, do as the header was not there
-+  mIsEnabled = PR_TRUE;
++  mIsEnabled = true;
 +  return NS_OK;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsInlineScript(const nsAString& aScript)
 +{
 +  LOG_XSS_CALL("Inline");
 +  LOG_XSS_1("script: %s",
 +            NS_ConvertUTF16toUTF8(Substring(aScript, 0, 70)).get());
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  nsXSSUtils::CheckInline(aScript, GetParams());
 +
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    NotifyViolation("Inline Script", aScript);
 +    return IsReportOnly();
 +  }
-+  return PR_TRUE;
++  return true;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsExternalScript(nsIURI *aURI)
 +{
 +  if (!aURI) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +#ifdef PR_LOGGING
 +  LOG_XSS_CALL("External");
 +  nsCAutoString spec;
 +  aURI->GetSpec(spec);
 +  LOG_XSS_1("script URI: %s", spec.get());
 +#endif
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  // fetch value from cache
-+  PRBool c;
++  bool c;
 +  nsAutoString domain;
 +  DomainMap& cache = GetDomainCache();
 +  nsXSSUtils::GetDomain(aURI, domain);
 +  if (cache.Get(domain, &c)) {
 +    return c;
 +  }
 +
 +  nsXSSUtils::CheckExternal(aURI, GetURI(), GetParams());
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    nsCAutoString spec;
 +    aURI->GetSpec(spec);
 +    NotifyViolation("External Script", NS_ConvertUTF8toUTF16(spec));
-+    cache.Put(domain, PR_FALSE);
++    cache.Put(domain, false);
 +    return IsReportOnly();
 +  }
-+  cache.Put(domain, PR_TRUE);
-+  return PR_TRUE;
++  cache.Put(domain, true);
++  return true;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsJSUrl(const nsAString& aURI)
 +{
 +  LOG_XSS_CALL("JSUrl");
 +  LOG_XSS_1("javascript url: %s",
 +            NS_ConvertUTF16toUTF8(Substring(aURI, 0, 70)).get());
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  nsAutoString escUri;
 +  nsXSSUtils::UnescapeLoop(aURI, escUri, mParentDoc);
 +  LOG_XSS_1("escaped javascript url: %s",
 +            NS_ConvertUTF16toUTF8(escUri).get());
 +
 +  nsXSSUtils::CheckInline(escUri, GetParams());
 +
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    NotifyViolation("JS URL", aURI);
 +    return IsReportOnly();
 +  }
-+  return PR_TRUE;
++  return true;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsEventListener(const nsAString& aScript)
 +{
 +  LOG_XSS_CALL("Event");
 +  LOG_XSS_1("Event: %s",
 +            NS_ConvertUTF16toUTF8(Substring(aScript, 0, 70)).get());
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  nsXSSUtils::CheckInline(aScript, GetParams());
 +
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    NotifyViolation("Event Listener", aScript);
 +    return IsReportOnly();
 +  }
-+  return PR_TRUE;
++  return true;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsBaseElement(nsIURI *aOldURI, nsIURI* aNewURI)
 +{
 +  if (!aOldURI || !aNewURI) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +#ifdef PR_LOGGING
 +  LOG_XSS_CALL("Base");
 +  nsCAutoString spec;
 +  aNewURI->GetSpec(spec);
 +  LOG_XSS_1("new URI: %s", spec.get());
 +#endif
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  // allow the base element to change the base url on the same
 +  // registered domain.
 +  nsAutoString oldD, newD;
 +  nsXSSUtils::GetDomain(aOldURI, oldD);
 +  nsXSSUtils::GetDomain(aNewURI, newD);
 +  if (oldD.Equals(newD)) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  nsXSSUtils::CheckExternal(aNewURI, GetURI(), GetParams());
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    nsCAutoString spec;
 +    aNewURI->GetSpec(spec);
 +    NotifyViolation("Base Element", NS_ConvertUTF8toUTF16(spec));
 +    return IsReportOnly();
 +  }
-+  return PR_TRUE;
++  return true;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsExternalObject(nsIURI *aURI)
 +{
 +  if (!aURI) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +#ifdef PR_LOGGING
 +  LOG_XSS_CALL("Object");
 +  nsCAutoString spec;
 +  aURI->GetSpec(spec);
 +  LOG_XSS_1("object URI: %s", spec.get());
 +#endif
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  // fetch value from cache
-+  PRBool c;
++  bool c;
 +  nsAutoString domain;
 +  DomainMap& cache = GetDomainCache();
 +  nsXSSUtils::GetDomain(aURI, domain);
 +  if (cache.Get(domain, &c)) {
 +    return c;
 +  }
 +
 +  nsXSSUtils::CheckExternal(aURI, GetURI(), GetParams());
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    nsCAutoString spec;
 +    aURI->GetSpec(spec);
 +    NotifyViolation("Object", NS_ConvertUTF8toUTF16(spec));
 +    return IsReportOnly();
 +  }
-+  return PR_TRUE;
++  return true;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsDataURL(nsIURI *aURI)
 +{
 +  if (!aURI) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  nsCAutoString spec;
 +  aURI->GetSpec(spec);
 +  LOG_XSS_CALL("DataURL");
 +  LOG_XSS_1("data URL: %s", spec.get());
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  nsXSSUtils::CheckInline(NS_ConvertUTF8toUTF16(spec), GetParams());
 +
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    NotifyViolation("Data URL", NS_ConvertUTF8toUTF16(spec));
 +    return IsReportOnly();
 +  }
-+  return PR_TRUE;
++  return true;
 +}
 +
-+PRBool
++bool
 +nsXSSFilter::PermitsJSAction(const nsAString& aCode)
 +{
 +  LOG_XSS_CALL("JSAction");
 +  LOG_XSS_1("JS: %s", NS_ConvertUTF16toUTF8(Substring(aCode, 0, 100)).get());
 +
 +  if (!IsEnabled()) {
-+    return PR_TRUE;
++    return true;
 +  }
 +
 +  nsXSSUtils::CheckInline(aCode, GetParams());
 +
 +  if (nsXSSUtils::HasAttack(GetParams())) {
 +    NotifyViolation("JS Action", aCode);
 +    return IsReportOnly();
 +  }
-+  return PR_TRUE;
++  return true;
 +}
 +
 +ParameterArray&
 +nsXSSFilter::GetParams()
 +{
 +  if (!mParamsInitialized) {
 +
 +    //get params
@@ -1573,38 +1573,38 @@ new file mode 100644
 +      if (bytesRead != len) {
 +        free(buf);
 +      }
 +      buf[len] = '\0';
 +      nsXSSUtils::ParsePOST(buf, mParams, mParentDoc);
 +      free(buf);
 +    }
 +
-+    mParamsInitialized = PR_TRUE;
++    mParamsInitialized = true;
 +
 +  }
 +
 +  return mParams;
 +}
 +
 +nsIURI*
 +nsXSSFilter::GetURI()
 +{
 +  return mParentDoc->GetDocumentURI();
 +}
 +
-+PRBool nsXSSFilter::IsEnabled() { return sXSSEnabled && mIsEnabled; }
-+PRBool nsXSSFilter::IsBlockMode() { return sBlockMode || mBlockMode; }
-+PRBool nsXSSFilter::IsReportOnly() { return sReportOnly; }
++bool nsXSSFilter::IsEnabled() { return sXSSEnabled && mIsEnabled; }
++bool nsXSSFilter::IsBlockMode() { return sBlockMode || mBlockMode; }
++bool nsXSSFilter::IsReportOnly() { return sReportOnly; }
 +
 +
 +class nsXSSNotifier: public nsRunnable
 +{
 +public:
-+  nsXSSNotifier(const char *policy, const nsAString& details, PRBool blockMode) :
++  nsXSSNotifier(const char *policy, const nsAString& details, bool blockMode) :
 +    mPolicy(policy), mDetails(details), mBlockMode(blockMode)
 +  { };
 +
 +  NS_IMETHOD Run() {
 +    LOG_XSS("Sending Observer Notification");
 +    nsCOMPtr<nsIObserverService> observerService =
 +      services::GetObserverService();
 +    if (!observerService) {
@@ -1621,17 +1621,17 @@ new file mode 100644
 +    return NS_OK;
 +  }
 +
 +
 +private:
 +  ~nsXSSNotifier() { };
 +  const char* mPolicy;
 +  nsString mDetails;
-+  PRBool mBlockMode;
++  bool mBlockMode;
 +};
 +
 +DomainMap&
 +nsXSSFilter::GetDomainCache()
 +{
 +  if (!mDomainCache.IsInitialized()) {
 +    mDomainCache.Init();
 +  }
@@ -1781,52 +1781,52 @@ new file mode 100644
 +   * Called after the XSS object is created to look at the
 +   * X-XSS-Protection header and configure the filter.
 +   */
 +  nsresult ScanRequestData();
 +  /**
 +   * Checks whether an inlined <script>...</script> element should be
 +   * executed.
 +   */
-+  PRBool PermitsInlineScript(const nsAString& aScript);
++  bool PermitsInlineScript(const nsAString& aScript);
 +  /**
 +   * Checks whether an external <script src=...></script> element
 +   * should be fetched and executed.
 +   */
-+  PRBool PermitsExternalScript(nsIURI *aURI);
++  bool PermitsExternalScript(nsIURI *aURI);
 +  /**
 +   * Checks whether a URL with the javascript: protocol should be
 +   * allowed. Lazy.
 +   */
-+  PRBool PermitsJSUrl(const nsAString& aURI);
++  bool PermitsJSUrl(const nsAString& aURI);
 +  /**
 +   * Checks whether an event listener should be fired due to an event.
 +   * Lazy, and caches results for further executions of the handler.
 +   */
-+  PRBool PermitsEventListener(const nsAString& aScript);
++  bool PermitsEventListener(const nsAString& aScript);
 +  /**
 +   * Checks whether the base URL for a document should be changed by a
 +   * <base href=... /> element.
 +   */
-+  PRBool PermitsBaseElement(nsIURI *aOldURI, nsIURI* aNewURI);
++  bool PermitsBaseElement(nsIURI *aOldURI, nsIURI* aNewURI);
 +  /**
 +   * Checks whether an object element specifying an external resource
 +   * should be fetched and loaded.
 +   */
-+  PRBool PermitsExternalObject(nsIURI *aURI);
++  bool PermitsExternalObject(nsIURI *aURI);
 +  /**
 +   * Checks whether a data URL that contains a script should be
 +   * executed. Lazy.
 +   */
-+  PRBool PermitsDataURL(nsIURI *aURI);
++  bool PermitsDataURL(nsIURI *aURI);
 +  /**
 +   * Checks whether the string argument from certain calls in
 +   * JavaScript (eval, setTimeout, setInterval) should be executed.
 +   */
-+  PRBool PermitsJSAction(const nsAString& code);
++  bool PermitsJSAction(const nsAString& code);
 +
 +  /**
 +   * Sets up Observers for the static preferences described below.
 +   */
 +  static void InitializeStatics();
 +  /**
 +   * Synced to preference security.xssfilter.enabled
 +   * The filter allows all if this is set to false.
@@ -1849,47 +1849,47 @@ new file mode 100644
 +  /**
 +   * An array of parameters extracted from the GET/POST
 +   * request. Lazily evaluated through GetParams().
 +   */
 +  ParameterArray mParams;
 +  /**
 +   * Whether we still need to fill in params. (b/c empty != uninitialized)
 +   */
-+  PRBool mParamsInitialized;
++  bool mParamsInitialized;
 +  /**
 +   * The document that owns the filter (through its principal).
 +   */
 +  nsIDocument *mParentDoc;
 +  /**
 +   * A cache of safe domains to avoid checking URLs for the same
 +   * domain twice. Used by external URLs and objects.
 +   */
 +  DomainMap mDomainCache;
 +  /**
 +   * Whether the XSS filter is enabled or disabled by the
 +   * X-XSS-Protection header.
 +   */
-+  PRBool mIsEnabled;
++  bool mIsEnabled;
 +  /**
 +   * Whether the XSS header explicitly requests block mode.
 +   */
-+  PRBool mBlockMode;
++  bool mBlockMode;
 +  /**
 +   * Returns true if XSS is enabled (pref && header)
 +   */
-+  PRBool IsEnabled();
++  bool IsEnabled();
 +  /**
 +   * Returns true if report only mode is enabled (pref).
 +   */
-+  PRBool IsReportOnly();
++  bool IsReportOnly();
 +  /**
 +   * Returns true if block mode is enabled (pref || header).
 +   */
-+  PRBool IsBlockMode();
++  bool IsBlockMode();
 +  /**
 +   * Gets the URL of the document for origin checks
 +   */
 +  nsIURI* GetURI();
 +  /**
 +   * Gets the array of parameters provided through the request for the
 +   * taint-inference algorithm. These are lazily evaluated.
 +   */
@@ -1993,34 +1993,34 @@ new file mode 100644
 +#define MIN_MATCH_LEN 5
 +#define SCRIPT_LEN 40
 +
 +#define PATH_CHARS " -/.;"
 +#define QUERY_CHARS " &=-"
 +#define REF_CHARS "-"
 +
 +Parameter::Parameter(const nsAString& aName, const nsAString& aValue,
-+                     PRBool aDangerous, PRBool aSpecial, PRBool aAttack)
++                     bool aDangerous, bool aSpecial, bool aAttack)
 +  : name(aName),
 +    value(aValue),
 +    attack(aAttack),
 +    dangerous(aDangerous),
 +    special(aSpecial)
 +{ }
 +
 +Parameter::Parameter(const char* aName, const char* aValue,
-+                     PRBool aDangerous, PRBool aSpecial, PRBool aAttack)
++                     bool aDangerous, bool aSpecial, bool aAttack)
 +  : name(NS_ConvertASCIItoUTF16(aName)),
 +    value(NS_ConvertASCIItoUTF16(aValue)),
 +    attack(aAttack),
 +    dangerous(aDangerous),
 +    special(aSpecial)
 +{ }
 +
-+PRBool
++bool
 +Parameter::operator==(const Parameter& other) const
 +{
 +  return name.Equals(other.name) && value.Equals(other.value) &&
 +    attack == other.attack && dangerous == other.dangerous &&
 +    special == other.special;
 +}
 +
 +/* for debugging */
@@ -2037,26 +2037,26 @@ new file mode 100644
 +  }
 +  if (special) {
 +    printf(" special");
 +  }
 +  printf("\n");
 +}
 +
 +/* [a-zA-Z0-9_] */
-+PRBool
++bool
 +IsAlphanumeric(PRUnichar c)
 +{
 +  return (PRUnichar('a') <= c && c <= PRUnichar('z')) ||
 +    (PRUnichar('A') <= c && c <= PRUnichar('Z')) ||
 +    (PRUnichar('0') <= c && c <= PRUnichar('9')) ||
 +    c == PRUnichar('_');
 +}
 +
-+PRBool
++bool
 +IsCharListed(PRUnichar c, const char *chars)
 +{
 +  for (PRUint8 i = 0; i < strlen(chars); i++)
 +    if (c == PRUnichar(chars[i])) {
 +      return true;
 +    }
 +  return false;
 +}
@@ -2139,17 +2139,17 @@ new file mode 100644
 +      result += NS_LITERAL_STRING("?");
 +    }
 +    result += query;
 +    if (!result.IsEmpty() && !ref.IsEmpty()) {
 +      result += NS_LITERAL_STRING("#");
 +    }
 +    result += ref;
 +    aParams.AppendElement(Parameter(NS_LITERAL_STRING("URL"),
-+                                    result, PR_TRUE, PR_TRUE));
++                                    result, true, true));
 +  }
 +  return NS_OK;
 +}
 +
 +nsresult
 +nsXSSUtils::ParsePOST(char *request, ParameterArray& aParams, nsIDocument* doc)
 +{
 +  char* separator = strstr(request, "\r\n\r\n");
@@ -2172,32 +2172,32 @@ new file mode 100644
 +    }
 +    // escape it like a normal url path
 +    nsXSSUtils::UnescapeLoop(params, params, doc);
 +    nsXSSUtils::TrimSafeChars(params, params, QUERY_CHARS);
 +    LOG_XSS_1("POST escaped payload: %s",
 +              NS_ConvertUTF16toUTF8(params).get());
 +    if (!params.IsEmpty()) {
 +      aParams.AppendElement(Parameter(NS_LITERAL_STRING("POST"),
-+                                      params, PR_TRUE, PR_TRUE));
++                                      params, true, true));
 +    }
 +  } else if(multipart && multipart < separator) {
 +    // TODO: this works, but it's not optimal: it would be best to
 +    // isolate the single parameters (and concatenate them in the
 +    // paramarray). this wastes at lot of cpu power during the string
 +    // matching to attempt matching data that is not under the control
 +    // of the attacker (MIME boundaries)
 +    nsAutoString params;
 +    params.Assign(NS_ConvertASCIItoUTF16(separator+4));
 +
 +    LOG_XSS_1("MIME POST payload: %s",
 +              NS_ConvertUTF16toUTF8(params).get());
 +    if (!params.IsEmpty()) {
 +      aParams.AppendElement(Parameter(NS_LITERAL_STRING("MIMEPOST"),
-+                                          params, PR_TRUE, PR_TRUE));
++                                          params, true, true));
 +    }
 +  } else {
 +    LOG_XSS("Unsupported or invalid POST request");
 +  }
 +  return NS_OK;
 +
 +}
 +
@@ -2240,17 +2240,17 @@ new file mode 100644
 +    if (rootElement->GetNameSpaceID() == kNameSpaceID_SVG) {
 +      LOG_XSS("SVG Doc, bailing out");
 +      return NS_OK; // SVG doesn't support setting a title
 +    }
 +  } else {
 +    LOG_XSS("No root element");
 +  }
 +
-+  mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, PR_TRUE);
++  mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
 +
 +  nsCOMPtr<nsINodeInfo> titleInfo;
 +  titleInfo =
 +    doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::title, nsnull,
 +                                        kNameSpaceID_XHTML,
 +                                        nsIDOMNode::ELEMENT_NODE);
 +  if (!titleInfo) {
 +    return NS_OK;
@@ -2305,17 +2305,17 @@ new file mode 100644
 +nsXSSUtils::InitializeStatics()
 +{
 +#ifdef PR_LOGGING
 +  gXssPRLog = PR_NewLogModule("XSS");
 +#endif
 +  LOG_XSS("Initialized Statics for XSS Utils");
 +}
 +
-+PRBool
++bool
 +nsXSSUtils::FindInlineXSS(const nsAString& aParam, const nsAString& aScript)
 +{
 +  MatchRes mres;
 +    // the script could be cut for efficiency, but since there is a
 +    // bound on the parameter length (which is usually a small number), it
 +    // probably does not improve performance much.
 +  if (aParam.Length() >= aScript.Length()) {
 +    // base case where the attacker injects the whole script. Since
@@ -2332,23 +2332,23 @@ new file mode 100644
 +  mres.ClearInvalidMatches(THRESHOLD);
 +
 +  for (PRUint32 i = 0; i < mres.elem_.Length(); i++) {
 +    LOG_XSS_2("Examining Match in FindInlineXSS: %d %d\n", mres[i].matchBeg_,
 +              mres[i].matchEnd_);
 +    // check: tainted string must not be at the beginning of the script
 +    if (mres[i].matchBeg_ == 0) {
 +      LOG_XSS("Match is at the beginning of script!");
-+      return PR_TRUE;
++      return true;
 +    }
 +  }
-+  return PR_FALSE;
++  return false;
 +}
 +
-+PRBool
++bool
 +nsXSSUtils::FindExternalXSS(const nsAString& aParam, nsIURI *aURI)
 +{
 +  MatchRes mres;
 +  nsAutoString url;
 +  // the string has already been converted up in the call stack. if
 +  // this is an expensive operation, i guess it could be passed
 +  // directly.
 +  nsCAutoString url8;
@@ -2362,20 +2362,20 @@ new file mode 100644
 +  }
 +  mres.ClearInvalidMatches(THRESHOLD);
 +  PRUint32 safeIndex = GetHostLimit(aURI);
 +  for (PRUint32 i = 0; i < mres.Length(); i++) {
 +    LOG_XSS_2("Match in FindExternalXSS: %d %d\n", mres[i].matchBeg_,
 +              mres[i].matchEnd_);
 +    if (mres[i].matchBeg_  < safeIndex) {
 +      LOG_XSS("Match controls host portion");
-+      return PR_TRUE;
++      return true;
 +    }
 +  }
-+  return PR_FALSE;
++  return false;
 +}
 +
 +nsresult
 +nsXSSUtils::CheckInline(const nsAString& aScript, ParameterArray& aParams)
 +{
 +  if (aParams.IsEmpty()) {
 +    return NS_OK;
 +  }
@@ -2415,24 +2415,24 @@ new file mode 100644
 +    // TODO: utf8.Lenth() returns bytes, not code points. the length
 +    // might be greater than the same str in utf16
 +    aURI->GetSpec(spec);
 +    aParams[i].attack = nsXSSUtils::FindExternalXSS(aParams[i].value, aURI);
 +  }
 +  return NS_OK;
 +}
 +
-+PRBool
++bool
 +nsXSSUtils::HasAttack(ParameterArray& aParams)
 +{
 +  for (PRUint32 i = 0; i < aParams.Length(); i++)
 +    if (aParams[i].attack) {
-+      return PR_TRUE;
++      return true;
 +    }
-+  return PR_FALSE;
++  return false;
 +}
 +
 +/*****************
 + * p1Match stuff
 + ****************/
 +
 +void
 +MatchRes::ClearInvalidMatches(double threshold)
@@ -2563,21 +2563,21 @@ new file mode 100644
 +#define NS_MIN3(a, b, c) NS_MIN(NS_MIN((a), (b)), (c))
 +#define MAX_DIST 100000000
 +#define dist(a, b) dist[(a)*(slen+1)+(b)]
 +#define NONE 4
 +#define SUBST 1
 +#define DELETE 2
 +#define INSERT 3
 +
-+PRBool printMatch = PR_FALSE;
-+PRBool printDistMatrix = PR_FALSE;
-+PRBool printApproxMatches = PR_FALSE;
-+PRBool printAllMatchSummary = PR_FALSE;
-+PRBool printAllMatches = PR_FALSE;
++bool printMatch = false;
++bool printDistMatrix = false;
++bool printApproxMatches = false;
++bool printAllMatchSummary = false;
++bool printAllMatches = false;
 +
 +inline void
 +printDist(PRInt32 *dist, PRInt32 slen, PRInt32 plen)
 +{
 +  if (printDistMatrix) {
 +    PRInt32 i, j;
 +    printf("  *");
 +    for (j = 0; j <= slen; j++)
@@ -3119,47 +3119,47 @@ new file mode 100644
 +    FAIL(_msg);                           \
 +  }
 +
 +/*** Testing structures ***/
 +
 +struct stringBool
 +{
 +  const char* val;
-+  PRBool rv;
++  bool rv;
 +};
 +
 +struct twoStrings
 +{
 +  const char *str1;
 +  const char *str2;
 +};
 +
 +struct twoStringsBool
 +{
 +  const char *p;
 +  const char *s;
-+  PRBool rv;
++  bool rv;
 +};
 +
 +struct twoChars
 +{
 +  const PRUnichar a,b;
 +};
 +
 +struct stringInt
 +{
 +  const char *str;
 +  const PRInt32 i;
 +};
 +
 +struct staticParam
 +{
 +  const char *name, *value;
-+  PRBool dangerous, special;
++  bool dangerous, special;
 +  Parameter ToParam() const
 +  {
 +    return Parameter(name, value, dangerous, special);
 +  };
 +};
 +/**** Testing data ****/
 +
 +const twoStrings suspiciousPathData[] = {
@@ -3192,35 +3192,35 @@ new file mode 100644
 +
 +const char *uri1 = "http://www.a.com";
 +const staticParam* uriData1 = nsnull;
 +const char *uri2 = "http://www.a.com/index.php?a=3";
 +const staticParam* uriData2 = nsnull;
 +const char *uri3 =
 +  "http://www.a.com/index.php?a=3&b=aaaaa&df=<script>xss()</script>";
 +const staticParam uriData3[] = {
-+  {"URL", "index.php?a=3&b=aaaaa&df=<script>xss()</script>", PR_TRUE, PR_TRUE},
++  {"URL", "index.php?a=3&b=aaaaa&df=<script>xss()</script>", true, true},
 +};
 +const char *uri4 =
 +  "http://www.a.com/index.php?a=3&b=<script>alert(1)</script>#hello";
 +const staticParam uriData4[] = {
-+  {"URL", "index.php?a=3&b=<script>alert(1)</script>#hello", PR_TRUE, PR_TRUE}
++  {"URL", "index.php?a=3&b=<script>alert(1)</script>#hello", true, true}
 +};
 +const char *uri5 = "http://www.a.com/dir/adf_en.html?a=4#hi";
 +const staticParam* uriData5 = nsnull;
 +const char *uri6 =
 +  "http://www.a.com/dir/<script>/index.php?param_1=<script>#<hello>aa";
 +const staticParam uriData6[] = {
 +  {"URL", "dir/<script>/index.php?param_1=<script>#<hello>aa",
-+   PR_TRUE, PR_TRUE}
++   true, true}
 +};
 +const char *uri7 =
 +  "http://www.a.com/index.php;param<script>param";
 +const staticParam uriData7[] = {
-+  {"URL", "index.php;param<script>param", PR_TRUE, PR_TRUE}
++  {"URL", "index.php;param<script>param", true, true}
 +};
 +
 +
 +
 +const char *p1pStr1 = "hello";
 +const char *p1sStr1 = "hello";
 +const MatchResElem p1Data1[] = {
 +  MatchResElem(0, 0, 5, nsnull),
@@ -3269,28 +3269,28 @@ new file mode 100644
 +};
 +const char *p1pStr10 = "<script>alert(\"xss attack\");</script>";
 +const char *p1sStr10 = "alert('xss attack');";
 +const MatchResElem p1Data10[] = {
 +  MatchResElem(60, 0, 20, nsnull),
 +};
 +
 +const twoStringsBool findInlineData[] = {
-+  { "<script>alert('xss')</script>", "alert('xss')", PR_TRUE },
-+  { "index<dff>.php?<script>alert(2);</script>", "alert(2);", PR_TRUE },
++  { "<script>alert('xss')</script>", "alert('xss')", true },
++  { "index<dff>.php?<script>alert(2);</script>", "alert(2);", true },
 +  { "index<dff>.php?<script>alert(2);</script>#<script>pippo()</script>",
-+    "xss()", PR_FALSE },
-+  { "abav' onmouseover='alert(\"xss\")'", "alert(\"xss\")", PR_TRUE}
++    "xss()", false },
++  { "abav' onmouseover='alert(\"xss\")'", "alert(\"xss\")", true}
 +};
 +
 +const twoStringsBool findExternalData[] = {
 +  { "<script src='http://evil.com/helloworld.js'></script>",
-+    "http://evil.com/helloworld.js", PR_TRUE },
++    "http://evil.com/helloworld.js", true },
 +  { "<script src='http://othersite.co.uk/helloworld.js'></script>",
-+    "http://evil.com/helloworld.js", PR_FALSE }
++    "http://evil.com/helloworld.js", false }
 +};
 +
 +//TODO: create a test that works with findoverlaps
 +
 +/*** Tests ***/
 +nsresult
 +TestLowerCaseASCII()
 +{
@@ -3524,17 +3524,17 @@ new file mode 100644
 +  return NS_OK;
 +}
 +
 +nsresult
 +TestFindInlineXSS()
 +{
 +  for (unsigned int i = 0; i < sizeof(findInlineData) / sizeof(twoStringsBool); i++) {
 +    nsAutoString p, s;
-+    PRBool rv;
++    bool rv;
 +    p = NS_ConvertASCIItoUTF16(findInlineData[i].p);
 +    s = NS_ConvertASCIItoUTF16(findInlineData[i].s);
 +    if (p.Length() > s.Length()) {
 +      rv = nsXSSUtils::FindInlineXSS(p, s);
 +    } else {
 +      rv = nsXSSUtils::FindInlineXSS(p, s);
 +    }
 +    TEST_ENSURE_COND(rv == findInlineData[i].rv, "FindInlineXSS");
@@ -3546,17 +3546,17 @@ new file mode 100644
 +TestFindExternalXSS()
 +{
 +  nsCOMPtr<nsIURI> uri;
 +  nsCOMPtr<nsIIOService> ios = do_GetIOService();
 +  for (unsigned int i = 0;
 +       i < sizeof(findExternalData) / sizeof(twoStringsBool); i++) {
 +    nsAutoString p;
 +    nsCAutoString u;
-+    PRBool rv;
++    bool rv;
 +    p.Assign(NS_ConvertASCIItoUTF16(findExternalData[i].p));
 +    u.Assign(findExternalData[i].s);
 +    ios->NewURI(u, nsnull, nsnull, getter_AddRefs(uri));
 +    if (p.Length() > u.Length()) {
 +      rv = nsXSSUtils::FindExternalXSS(p, uri);
 +    } else {
 +      rv = nsXSSUtils::FindExternalXSS(p, uri);
 +    }
@@ -3570,26 +3570,26 @@ new file mode 100644
 +TestCheckInline()
 +{
 +  nsAutoString script;
 +  ParameterArray params;
 +
 +  // reversed
 +  script.Assign(NS_LITERAL_STRING("alert('xss attack')"));
 +  params.AppendElement(Parameter("URL", "<script>hello world</script>",
-+                                 PR_TRUE, PR_TRUE));
++                                 true, true));
 +  nsXSSUtils::CheckInline(script, params);
-+  TEST_ENSURE_COND(params[0].attack == PR_FALSE, "CheckInline");
++  TEST_ENSURE_COND(params[0].attack == false, "CheckInline");
 +  params.Clear();
 +
 +  script.Assign(NS_LITERAL_STRING("alert('xss attack')"));
 +  params.AppendElement(Parameter("URL", "<script>alert(\"xss attack\")</script>",
-+                                 PR_TRUE, PR_TRUE));
++                                 true, true));
 +  nsXSSUtils::CheckInline(script, params);
-+  TEST_ENSURE_COND(params[0].attack == PR_TRUE, "CheckInline");
++  TEST_ENSURE_COND(params[0].attack == true, "CheckInline");
 +  params.Clear();
 +
 +  return NS_OK;
 +
 +}
 +
 +nsresult
 +TestCheckExternal()
@@ -3601,36 +3601,36 @@ new file mode 100644
 +
 +  pU.Assign(NS_LITERAL_CSTRING("http://www.localhost.net/pages/stuff.index.html"));
 +  ios->NewURI(pU, nsnull, nsnull, getter_AddRefs(pageUri));
 +
 +  u.Assign(NS_LITERAL_CSTRING("http://www.google.com/scripts/script.js"));
 +  ios->NewURI(u, nsnull, nsnull, getter_AddRefs(uri));
 +  params.AppendElement(
 +    Parameter("URL", "<script src='http://www.google.com/helloworld/gino.js'></script>",
-+              PR_TRUE, PR_TRUE));
++              true, true));
 +  nsXSSUtils::CheckExternal(uri, pageUri, params);
-+  TEST_ENSURE_COND(params[0].attack == PR_FALSE, "CheckExternal");
++  TEST_ENSURE_COND(params[0].attack == false, "CheckExternal");
 +  params.Clear();
 +
 +  u.Assign(NS_LITERAL_CSTRING("http://hello.localhost.net/scripts/script.js"));
 +  ios->NewURI(u, nsnull, nsnull, getter_AddRefs(uri));
 +  params.AppendElement(Parameter("a", "<script src='hello.localhost.net/scripts/script.js'></script>",
-+                                 PR_TRUE, PR_FALSE));
++                                 true, false));
 +  nsXSSUtils::CheckExternal(uri, pageUri, params);
-+  TEST_ENSURE_COND(params[0].attack == PR_FALSE, "CheckExternal");
++  TEST_ENSURE_COND(params[0].attack == false, "CheckExternal");
 +  params.Clear();
 +
 +  u.Assign(NS_LITERAL_CSTRING("http://www.pippo.com/script.js"));
 +  ios->NewURI(u, nsnull, nsnull, getter_AddRefs(uri));
-+  params.AppendElement(Parameter("URL1", "<script src='http://www.pippo.com/script.js'></script>", PR_TRUE, PR_TRUE));
-+  params.AppendElement(Parameter("URL2", "<script src='http://www.localhost.com/script.js'></script>", PR_TRUE, PR_TRUE));
++  params.AppendElement(Parameter("URL1", "<script src='http://www.pippo.com/script.js'></script>", true, true));
++  params.AppendElement(Parameter("URL2", "<script src='http://www.localhost.com/script.js'></script>", true, true));
 +  nsXSSUtils::CheckExternal(uri, pageUri, params);
-+  TEST_ENSURE_COND(params[0].attack == PR_TRUE, "CheckExternal");
-+  TEST_ENSURE_COND(params[1].attack == PR_FALSE, "CheckExternal");
++  TEST_ENSURE_COND(params[0].attack == true, "CheckExternal");
++  TEST_ENSURE_COND(params[1].attack == false, "CheckExternal");
 +
 +  return NS_OK;
 +}
 +
 +nsresult
 +nsXSSUtilsWrapper::Test()
 +{
 +#ifdef PR_LOGGING
@@ -3731,23 +3731,23 @@ new file mode 100644
 + * the filter: the url of the webpage and the body of POST
 + * requests. Look at ParseURI and ParsePOST for the actual logic.  An
 + * earlier iteration of the filter would break down the URL into many
 + * different parameters, and this class still supports that if needed.
 + * I think the dangerous and special fields are not actively used anymore.
 + */
 +struct Parameter {
 +  nsString name, value;
-+  PRBool attack, dangerous, special;
++  bool attack, dangerous, special;
 +  Parameter(const nsAString& aName, const nsAString& aValue,
-+            PRBool aDangerous, PRBool aSpecial, PRBool aAttack = PR_FALSE);
++            bool aDangerous, bool aSpecial, bool aAttack = false);
 +  Parameter(const char* aName, const char* aValue,
-+            PRBool aDangerous, PRBool aSpecial, PRBool aAttack = PR_FALSE);
++            bool aDangerous, bool aSpecial, bool aAttack = false);
 +  // for debugging
-+  PRBool operator==(const Parameter& other) const;
++  bool operator==(const Parameter& other) const;
 +  void print() const;
 +};
 +
 +class nsIURI;
 +
 +typedef nsTArray<Parameter> ParameterArray;
 +
 +/**
@@ -3760,33 +3760,33 @@ new file mode 100644
 +  PRInt32 dist_;		// edit distance
 +  PRUint32 matchBeg_;	// start and
 +  PRUint32 matchEnd_;	//   end of match
 +  PRUint8 *opmap_;		// table of edit operator costs
 +
 + public:
 +  MatchResElem(PRUint32 d, PRUint32 b, PRUint32 e, PRUint8 *opmap)
 +	{dist_ = d; matchBeg_ = b; matchEnd_ = e; opmap_ = opmap; };
-+  PRBool operator==(const MatchResElem& other) const
++  bool operator==(const MatchResElem& other) const
 +  { return dist_ == other.dist_ && matchBeg_ == other.matchBeg_ &&
 +      matchEnd_ == other.matchEnd_; }; // don't compare opmap for testing
 +  // are we leaking mem with opmap?
 +};
 +
 +
 +typedef nsTArray<MatchResElem> Matches;
 +/**
 + * Represents a Match Result as returned by p1FastMach.
 + */
 +class MatchRes {
 + public:
 +  PRInt32 costThresh_;	// minimum edit distance for matches
 +  PRInt32 bestDist_;	// best obseved edit distance in the matches found
 +  Matches elem_;	// list of matches found
-+  PRBool HasMatches() { return !elem_.IsEmpty(); };
++  bool HasMatches() { return !elem_.IsEmpty(); };
 +  MatchResElem& operator[] (PRUint32 i) { return elem_.ElementAt(i); };
 +  PRUint32 Length() const { return elem_.Length(); };
 +  void ClearInvalidMatches(double threshold);
 +};
 +
 +class DistMetric {
 + public:
 +  static PRUint8 GetICost(PRUnichar sc);
@@ -3801,28 +3801,28 @@ new file mode 100644
 +  typedef const PRUnichar& KeyType;
 +  typedef const PRUnichar* KeyTypePointer;
 +
 +  nsUnicharHashKey(KeyTypePointer aKey) : mValue(*aKey) { }
 +  nsUnicharHashKey(const nsUnicharHashKey& toCopy) : mValue(toCopy.mValue) { }
 +  ~nsUnicharHashKey() { }
 +
 +  KeyType GetKey() const { return mValue; }
-+  PRBool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; }
++  bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; }
 +
 +  static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
 +  static PLDHashNumber HashKey(KeyTypePointer aKey) { return *aKey; }
-+  enum { ALLOW_MEMMOVE = PR_TRUE };
++  enum { ALLOW_MEMMOVE = true };
 +
 +private:
 +  const PRUnichar mValue;
 +};
 +// why can't we simply template the entryHeader as PLDHashEntryHdr<PRUnichar>?
 +typedef nsDataHashtable<nsUnicharHashKey, PRInt32> UnicharMap;
-+typedef nsDataHashtableMT<nsStringHashKey, PRBool> DomainMap;
++typedef nsDataHashtableMT<nsStringHashKey, bool> DomainMap;
 +
 +
 +class DistVector {
 +public:
 +  DistVector();
 +  PRInt32 GetDiff(PRUnichar c);
 +  void SetDiff(PRUnichar c, PRInt32 val);
 +  //PRInt32& operator[] (PRUnichar c);  can't get a reference to nsDataHashtable!
@@ -3856,23 +3856,23 @@ new file mode 100644
 +   * matched interval on p instead of s.
 +   */
 +  static nsresult P1FastMatchReverse(const nsAString& s, const nsAString& p,
 +                                     double distThreshold, MatchRes &mres);
 +  /**
 +   * Returns whether the current parameter represents an XSS attack
 +   * for the script
 +   */
-+  static PRBool FindInlineXSS(const nsAString& aParam,
++  static bool FindInlineXSS(const nsAString& aParam,
 +                              const nsAString& aScript);
 +  /**
 +   * Returns whether the current parameter represents an XSS attack
 +   * for the url
 +   */
-+  static PRBool FindExternalXSS(const nsAString& aParam, nsIURI *aUri);
++  static bool FindExternalXSS(const nsAString& aParam, nsIURI *aUri);
 +  /**
 +   * Returns the registered domain name. Handles 2nd-level tlds such
 +   * as google.co.uk
 +   */
 +  static nsresult GetDomain(nsIURI* aUri, nsAString& result);
 +  /**
 +   *  Main interface for XSSFilter. These two function detect which
 +   *  params contribute to an injected script or url.
@@ -3918,22 +3918,22 @@ new file mode 100644
 +   * appending it to aParams.
 +   */
 +  static nsresult ParsePOST(char *request, ParameterArray& aParams,
 +                            nsIDocument* doc);
 +  /**
 +   * Returns true if the string contains anything other than
 +   * [a-zA-Z0-9 _-=&]
 +   */
-+  static PRBool IsQueryDangerous(const nsAString& aString);
++  static bool IsQueryDangerous(const nsAString& aString);
 +  /**
 +   * Checks whether at least one of the parameters in the array
 +   * represents an XSS attack.
 +   */
-+  static PRBool HasAttack(ParameterArray& aParams);
++  static bool HasAttack(ParameterArray& aParams);
 +  /**
 +   * Initialize the logger and other static variables.
 +   */
 +  static void InitializeStatics();
 +};
 +
 +
 +#define NS_XSSUTILS_CID \
@@ -4942,17 +4942,17 @@ diff --git a/content/events/src/nsEventL
 +  }
 +
 +  // 1. xss filter
 +  nsIDocument* doc = nsnull;
 +  nsCOMPtr<nsINode> node = do_QueryInterface(aCurrentTarget);
 +  if (!node) {
 +    PR_LOG(gXssPRLog, PR_LOG_DEBUG,
 +           ("CheckEventForXSS:no node"));
-+    nsCOMPtr<nsIWindow
++    //nsCOMPtr<nsIWindow> win = do_QueryInterface(aCurrentTarget);
 +    return false;
 +  }
 +  nsIPrincipal* principal = node->NodePrincipal();
 +  if (!principal) {
 +    PR_LOG(gXssPRLog, PR_LOG_DEBUG,
 +           ("CheckEventForXSS:no principal"));
 +    return false;
 +  }