Un-fold browsercomps.* from libxul

This resolves #16.
This commit is contained in:
wolfbeast 2018-02-11 13:01:08 +01:00 committed by Roy Tam
commit d07bf4bba2
13 changed files with 55 additions and 43 deletions

View file

@ -185,15 +185,9 @@ IsDocumentElement(const char *start, const char* end)
static bool
ContainsTopLevelSubstring(nsACString& dataString, const char *substring)
{
nsACString::const_iterator start, end;
dataString.BeginReading(start);
dataString.EndReading(end);
if (!FindInReadable(nsCString(substring), start, end)){
int32_t offset = dataString.Find(substring);
if (offset == -1)
return false;
}
auto offset = start.get() - dataString.Data();
const char *begin = dataString.BeginReading();
@ -318,10 +312,9 @@ nsFeedSniffer::GetMIMETypeFromContent(nsIRequest* request,
// RSS 1.0
if (!isFeed) {
bool foundNS_RDF = FindInReadable(NS_LITERAL_CSTRING(NS_RDF), dataString);
bool foundNS_RSS = FindInReadable(NS_LITERAL_CSTRING(NS_RSS), dataString);
isFeed = ContainsTopLevelSubstring(dataString, "<rdf:RDF") &&
foundNS_RDF && foundNS_RSS;
dataString.Find(NS_RDF) != -1 &&
dataString.Find(NS_RSS) != -1;
}
// If we sniffed a feed, coerce our internal type