nsFeedSniffer.cpp File Reference
#include "nsFeedSniffer.h"
#include "prmem.h"
#include "nsNetCID.h"
#include "nsXPCOM.h"
#include "nsCOMPtr.h"
#include "nsStringStream.h"
#include "nsBrowserCompsCID.h"
#include "nsICategoryManager.h"
#include "nsIServiceManager.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsIStreamConverterService.h"
#include "nsIStreamConverter.h"
#include "nsIStreamListener.h"
#include "nsIHttpChannel.h"
#include "nsIMIMEHeaderParam.h"
#include "nsMimeTypes.h"
Include dependency graph for nsFeedSniffer.cpp:

Go to the source code of this file.

Macros

#define TYPE_ATOM   "application/atom+xml"
 
#define TYPE_RSS   "application/rss+xml"
 
#define TYPE_MAYBE_FEED   "application/vnd.mozilla.maybe.feed"
 
#define NS_RDF   "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 
#define NS_RSS   "http://purl.org/rss/1.0/"
 
#define MAX_BYTES   512
 

Functions

 NS_IMPL_ISUPPORTS3 (nsFeedSniffer, nsIContentSniffer, nsIStreamListener, nsIRequestObserver) nsresult nsFeedSniffer
 
template<int N>
static PRBool StringBeginsWithLowercaseLiteral (nsAString &aString, const char(&aSubstring)[N])
 
PRBool HasAttachmentDisposition (nsIHttpChannel *httpChannel)
 
static const char * FindChar (char c, const char *begin, const char *end)
 
static PRBool IsDocumentElement (const char *start, const char *end)
 
static PRBool ContainsTopLevelSubstring (nsACString &dataString, const char *substring)
 

Macro Definition Documentation

#define MAX_BYTES   512

Definition at line 72 of file nsFeedSniffer.cpp.

#define NS_RDF   "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

Definition at line 69 of file nsFeedSniffer.cpp.

#define NS_RSS   "http://purl.org/rss/1.0/"

Definition at line 70 of file nsFeedSniffer.cpp.

#define TYPE_ATOM   "application/atom+xml"

Definition at line 65 of file nsFeedSniffer.cpp.

#define TYPE_MAYBE_FEED   "application/vnd.mozilla.maybe.feed"

Definition at line 67 of file nsFeedSniffer.cpp.

#define TYPE_RSS   "application/rss+xml"

Definition at line 66 of file nsFeedSniffer.cpp.

Function Documentation

static PRBool ContainsTopLevelSubstring ( nsACString &  dataString,
const char *  substring 
)
static

Determines whether or not a string exists as the root element in an XML data string buffer.

Parameters
dataStringThe data being sniffed
substringThe substring being tested for existence and root-ness.
Returns
PR_TRUE if the substring exists and is the documentElement, PR_FALSE otherwise.

Definition at line 251 of file nsFeedSniffer.cpp.

Here is the call graph for this function:

static const char* FindChar ( char  c,
const char *  begin,
const char *  end 
)
static
Returns
the first occurrence of a character within a string buffer, or nsnull if not found

Definition at line 185 of file nsFeedSniffer.cpp.

Here is the caller graph for this function:

PRBool HasAttachmentDisposition ( nsIHttpChannel *  httpChannel)

Definition at line 135 of file nsFeedSniffer.cpp.

Here is the call graph for this function:

static PRBool IsDocumentElement ( const char *  start,
const char *  end 
)
static

Determine if a substring is the "documentElement" in the document.

All of our sniffed substrings: <rss, <feed, <rdf:RDF must be the "document" element within the XML DOM, i.e. the root container element. Otherwise, it's possible that someone embedded one of these tags inside a document of another type, e.g. a HTML document, and we don't want to show the preview page if the document isn't actually a feed.

Parameters
startThe beginning of the data being sniffed
endThe end of the data being sniffed, right before the substring that was found.
Returns
PR_TRUE if the found substring is the documentElement, PR_FALSE otherwise.

Definition at line 213 of file nsFeedSniffer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMPL_ISUPPORTS3 ( nsFeedSniffer  ,
nsIContentSniffer  ,
nsIStreamListener  ,
nsIRequestObserver   
)

Definition at line 74 of file nsFeedSniffer.cpp.

template<int N>
static PRBool StringBeginsWithLowercaseLiteral ( nsAString &  aString,
const char(&)  aSubstring[N] 
)
static

Definition at line 126 of file nsFeedSniffer.cpp.

Here is the caller graph for this function: