Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d84ddf2

Browse files
committed
Replacing os.sep constructs with os.path.join
1 parent 2f1607b commit d84ddf2

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ def dataToOutFile(filename, data):
837837
retVal = None
838838

839839
if data:
840-
retVal = "%s%s%s" % (conf.filePath, os.sep, filePathToSafeString(filename))
840+
retVal = os.path.join(conf.filePath, filePathToSafeString(filename))
841841

842842
with codecs.open(retVal, "wb", UNICODE_ENCODING) as f:
843843
f.write(data)

lib/core/dump.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _write(self, data, newline=True, console=True, content_type=None):
7474
kb.dataOutputFlag = True
7575

7676
def setOutputFile(self):
77-
self._outputFile = "%s%slog" % (conf.outputPath, os.sep)
77+
self._outputFile = os.path.join(conf.outputPath, "log")
7878
try:
7979
self._outputFP = codecs.open(self._outputFile, "ab" if not conf.flushSession else "wb", UNICODE_ENCODING)
8080
except IOError, ex:
@@ -380,15 +380,15 @@ def dbTableValues(self, tableValues):
380380
self._write(tableValues, content_type=CONTENT_TYPE.DUMP_TABLE)
381381
return
382382

383-
dumpDbPath = "%s%s%s" % (conf.dumpPath, os.sep, re.sub(r"[^\w]", "_", unsafeSQLIdentificatorNaming(db)))
383+
dumpDbPath = os.path.join(conf.dumpPath, re.sub(r"[^\w]", "_", unsafeSQLIdentificatorNaming(db)))
384384

385385
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
386-
replication = Replication("%s%s%s.sqlite3" % (conf.dumpPath, os.sep, unsafeSQLIdentificatorNaming(db)))
386+
replication = Replication(os.path.join(conf.dumpPath, "%s.sqlite3" % unsafeSQLIdentificatorNaming(db)))
387387
elif conf.dumpFormat in (DUMP_FORMAT.CSV, DUMP_FORMAT.HTML):
388388
if not os.path.isdir(dumpDbPath):
389389
os.makedirs(dumpDbPath, 0755)
390390

391-
dumpFileName = "%s%s%s.%s" % (dumpDbPath, os.sep, unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower())
391+
dumpFileName = os.path.join(dumpDbPath, "%s.%s" % (unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower()))
392392
appendToFile = os.path.isfile(dumpFileName) and any((conf.limitStart, conf.limitStop))
393393
dumpFP = openFile(dumpFileName, "wb" if not appendToFile else "ab")
394394

lib/core/target.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def _setHashDB():
304304
"""
305305

306306
if not conf.hashDBFile:
307-
conf.hashDBFile = conf.sessionFile or "%s%ssession.sqlite" % (conf.outputPath, os.sep)
307+
conf.hashDBFile = conf.sessionFile or os.path.join(conf.outputPath, "session.sqlite")
308308

309309
if os.path.exists(conf.hashDBFile):
310310
if conf.flushSession:
@@ -432,7 +432,7 @@ def _setResultsFile():
432432
return
433433

434434
if not conf.resultsFP:
435-
conf.resultsFilename = "%s%s%s" % (paths.SQLMAP_OUTPUT_PATH, os.sep, time.strftime(RESULTS_FILE_FORMAT).lower())
435+
conf.resultsFilename = os.path.join(paths.SQLMAP_OUTPUT_PATH, time.strftime(RESULTS_FILE_FORMAT).lower())
436436
conf.resultsFP = codecs.open(conf.resultsFilename, "w+", UNICODE_ENCODING, buffering=0)
437437
conf.resultsFP.writelines("Target URL,Place,Parameter,Techniques%s" % os.linesep)
438438

@@ -498,7 +498,7 @@ def _createTargetDirs():
498498

499499
paths.SQLMAP_OUTPUT_PATH = tempDir
500500

501-
conf.outputPath = "%s%s%s" % (paths.SQLMAP_OUTPUT_PATH, os.sep, conf.hostname)
501+
conf.outputPath = os.path.join(paths.SQLMAP_OUTPUT_PATH, conf.hostname)
502502

503503
if not os.path.isdir(conf.outputPath):
504504
try:

0 commit comments

Comments
 (0)