#ifndef XSSAuditor_h
#define XSSAuditor_h
#include "HTMLToken.h"
#include "HTTPParsers.h"
#include "SuffixTree.h"
namespace WebCore {
class HTMLDocumentParser;
class XSSAuditor {
WTF_MAKE_NONCOPYABLE(XSSAuditor);
public:
explicit XSSAuditor(HTMLDocumentParser*);
void filterToken(HTMLToken&);
private:
static const size_t kMaximumFragmentLengthTarget = 100;
enum State {
Uninitialized,
Initialized
};
enum AttributeKind {
NormalAttribute,
SrcLikeAttribute,
ScriptLikeAttribute
};
void init();
bool filterStartToken(HTMLToken&);
void filterEndToken(HTMLToken&);
bool filterCharacterToken(HTMLToken&);
bool filterScriptToken(HTMLToken&);
bool filterObjectToken(HTMLToken&);
bool filterParamToken(HTMLToken&);
bool filterEmbedToken(HTMLToken&);
bool filterAppletToken(HTMLToken&);
bool filterIframeToken(HTMLToken&);
bool filterMetaToken(HTMLToken&);
bool filterBaseToken(HTMLToken&);
bool filterFormToken(HTMLToken&);
bool eraseDangerousAttributesIfInjected(HTMLToken&);
bool eraseAttributeIfInjected(HTMLToken&, const QualifiedName&, const String& replacementValue = String(), AttributeKind treatment = NormalAttribute);
String decodedSnippetForToken(const HTMLToken&);
String decodedSnippetForName(const HTMLToken&);
String decodedSnippetForAttribute(const HTMLToken&, const HTMLToken::Attribute&, AttributeKind treatment = NormalAttribute);
String decodedSnippetForJavaScript(const HTMLToken&);
bool isContainedInRequest(const String&);
bool isSameOriginResource(const String& url);
HTMLDocumentParser* m_parser;
bool m_isEnabled;
XSSProtectionDisposition m_xssProtection;
String m_decodedURL;
String m_decodedHTTPBody;
OwnPtr<SuffixTree<ASCIICodebook> > m_decodedHTTPBodySuffixTree;
State m_state;
String m_cachedDecodedSnippet;
bool m_shouldAllowCDATA;
unsigned m_scriptTagNestingLevel;
bool m_notifiedClient;
};
}
#endif