6161from lib .core .settings import SQLITE_ALIASES
6262from lib .core .settings import ACCESS_ALIASES
6363from lib .core .settings import FIREBIRD_ALIASES
64-
64+ from lib .core .settings import DUMP_NEWLINE_MARKER
65+ from lib .core .settings import DUMP_DEL_MARKER
66+ from lib .core .settings import DUMP_TAB_MARKER
67+ from lib .core .settings import DUMP_START_MARKER
68+ from lib .core .settings import DUMP_STOP_MARKER
6569
6670class UnicodeRawConfigParser (RawConfigParser ):
6771 """
@@ -558,9 +562,20 @@ def replaceNewlineTabs(inpStr, stdout=False):
558562 if stdout :
559563 replacedString = inpStr .replace ("\n " , " " ).replace ("\t " , " " )
560564 else :
561- replacedString = inpStr .replace ("\n " , "__NEWLINE__" ).replace ("\t " , "__TAB__" )
565+ replacedString = inpStr .replace ("\n " , DUMP_NEWLINE_MARKER ).replace ("\t " , DUMP_TAB_MARKER )
566+
567+ replacedString = replacedString .replace (kb .misc .delimiter , DUMP_DEL_MARKER )
568+
569+ return replacedString
570+
571+ def restoreDumpMarkedChars (inpStr , onlyNewlineTab = False ):
572+ replacedString = inpStr
562573
563- replacedString = replacedString .replace (kb .misc .delimiter , "__DEL__" )
574+ if isinstance (replacedString , basestring ):
575+ replacedString = replacedString .replace (DUMP_NEWLINE_MARKER , "\n " ).replace (DUMP_TAB_MARKER , "\t " )
576+ if not onlyNewlineTab :
577+ replacedString = replacedString .replace (DUMP_START_MARKER , "" ).replace (DUMP_STOP_MARKER , "" )
578+ replacedString = replacedString .replace (DUMP_DEL_MARKER , ", " )
564579
565580 return replacedString
566581
@@ -838,13 +853,13 @@ def parseUnionPage(output, expression, partial=False, condition=None, sort=True)
838853 data = []
839854
840855 outCond1 = ( output .startswith (kb .misc .start ) and output .endswith (kb .misc .stop ) )
841- outCond2 = ( output .startswith ("__START__" ) and output .endswith ("__STOP__" ) )
856+ outCond2 = ( output .startswith (DUMP_START_MARKER ) and output .endswith (DUMP_STOP_MARKER ) )
842857
843858 if outCond1 or outCond2 :
844859 if outCond1 :
845860 regExpr = '%s(.*?)%s' % (kb .misc .start , kb .misc .stop )
846861 elif outCond2 :
847- regExpr = '__START__ (.*?)__STOP__'
862+ regExpr = '%s (.*?)%s' % ( DUMP_START_MARKER , DUMP_STOP_MARKER )
848863
849864 output = re .findall (regExpr , output , re .S )
850865
@@ -855,7 +870,7 @@ def parseUnionPage(output, expression, partial=False, condition=None, sort=True)
855870 )
856871
857872 if partial or not condition :
858- logOutput = "" .join (["__START__%s__STOP__ " % replaceNewlineTabs (value ) for value in output ])
873+ logOutput = "" .join (["%s%s%s " % ( DUMP_START_MARKER , replaceNewlineTabs (value ), DUMP_STOP_MARKER ) for value in output ])
859874 dataToSessionFile ("[%s][%s][%s][%s][%s]\n " % (conf .url , kb .injPlace , conf .parameters [kb .injPlace ], expression , logOutput ))
860875
861876 if sort :
@@ -864,8 +879,8 @@ def parseUnionPage(output, expression, partial=False, condition=None, sort=True)
864879 for entry in output :
865880 info = []
866881
867- if "__DEL__" in entry :
868- entry = entry .split ("__DEL__" )
882+ if DUMP_DEL_MARKER in entry :
883+ entry = entry .split (DUMP_DEL_MARKER )
869884 else :
870885 entry = entry .split (kb .misc .delimiter )
871886
0 commit comments