From 3a5f0760f61ef7fe5711962db063a48f0b94425c Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 23 Jan 2011 10:12:01 +0000 Subject: [PATCH] minor optimization (only way to prematurely stop SAX parser) --- lib/core/exception.py | 3 +++ lib/parse/html.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/core/exception.py b/lib/core/exception.py index 83eaa8b31..bf4d85d87 100644 --- a/lib/core/exception.py +++ b/lib/core/exception.py @@ -20,6 +20,9 @@ class sqlmapConnectionException(Exception): class sqlmapDataException(Exception): pass +class sqlmapEndSAXParsing(Exception): + pass + class sqlmapFilePathException(Exception): pass diff --git a/lib/parse/html.py b/lib/parse/html.py index c36bcb433..419aa66c7 100644 --- a/lib/parse/html.py +++ b/lib/parse/html.py @@ -16,6 +16,7 @@ from lib.core.common import parseXmlFile from lib.core.common import sanitizeStr from lib.core.data import kb from lib.core.data import paths +from lib.core.exception import sqlmapEndSAXParsing from lib.core.threads import getCurrentThreadData class htmlHandler(ContentHandler): @@ -47,6 +48,7 @@ class htmlHandler(ContentHandler): self.__match = None threadData = getCurrentThreadData() threadData.lastErrorPage = (threadData.lastRequestUID, self.__page) + raise sqlmapEndSAXParsing def htmlParser(page): """ @@ -58,7 +60,11 @@ def htmlParser(page): checkFile(xmlfile) page = sanitizeStr(page) handler = htmlHandler(page) - parseXmlFile(xmlfile, handler) + + try: + parseXmlFile(xmlfile, handler) + except sqlmapEndSAXParsing: + pass if handler.dbms and handler.dbms not in kb.htmlFp: kb.lastParserStatus = handler.dbms