Ejemplo n.º 1
0
static void
__ReplaceCSubstring (nsACString &string, const char* replace, const char* with)
{
	PRInt32 i = string.Find (replace);
	while ( i >= 0 ) {
  	string.Replace (i, strlen (replace), with);
  	i = string.Find (replace);
  }
}
Ejemplo n.º 2
0
/**
 * Determines whether or not a string exists as the root element in an XML data
 * string buffer.
 * @param   dataString
 *          The data being sniffed
 * @param   substring
 *          The substring being tested for existence and root-ness.
 * @returns true if the substring exists and is the documentElement, false
 *          otherwise.
 */
static bool
ContainsTopLevelSubstring(nsACString& dataString, const char *substring) 
{
  int32_t offset = dataString.Find(substring);
  if (offset == -1)
    return false;

  const char *begin = dataString.BeginReading();

  // Only do the validation when we find the substring.
  return IsDocumentElement(begin, begin + offset);
}