Nosql-Exploitation-Framework icon indicating copy to clipboard operation
Nosql-Exploitation-Framework copied to clipboard

Code Quality, Unicode Safe Read

Open ajinabraham opened this issue 9 years ago • 2 comments

Lot of places have open file pointers like https://github.com/torque59/Nosql-Exploitation-Framework/blob/master/dbattacks/utils.py#L116 close all the file pointers after use. This will save memory.

Also replace open with io.open which is unicode safe. usingwith will handle file pointers efficiently and you don't have to close them explicitly.

example code

with io.open(file_path, mode='r', encoding="utf8", errors="ignore") as f:
     dat = f.read()

ajinabraham avatar Aug 01 '16 16:08 ajinabraham

io.open is the alias for open in python, so both are same i guess, as for closing the files , i am cleaning up the code, should see an update soon.

torque59 avatar Aug 01 '16 17:08 torque59

both are same in python3, but not in python2. If you need to read data that contain Unicode, using open will throw errors. If you use io.open specifying the encoding and ignores error .it will work gracefully

ajinabraham avatar Aug 02 '16 04:08 ajinabraham